diff --git a/eval.c b/eval.c index 4dc50e71..f9ed2efe 100644 --- a/eval.c +++ b/eval.c @@ -2469,8 +2469,9 @@ sexp sexp_load_standard_env (sexp ctx, sexp e, sexp version) { if (! sexp_envp(tmp=sexp_global(ctx, SEXP_G_CONFIG_ENV))) { tmp = sexp_make_env(ctx); if (! sexp_exceptionp(tmp)) { - sexp_env_copy(ctx, tmp, e, SEXP_FALSE); sexp_global(ctx, SEXP_G_CONFIG_ENV) = tmp; + sexp_env_copy(ctx, tmp, e, SEXP_FALSE); + sexp_load_module_file(ctx, sexp_config_file, tmp); sexp_env_define(ctx, tmp, sym, tmp); } } diff --git a/main.c b/main.c index 8da4643f..03bd3b34 100644 --- a/main.c +++ b/main.c @@ -49,7 +49,9 @@ static sexp check_exception (sexp ctx, sexp res) { sexp err; if (res && sexp_exceptionp(res)) { err = sexp_current_error_port(ctx); - if (sexp_oportp(err)) sexp_print_exception(ctx, res, err); + if (! sexp_oportp(err)) + err = sexp_make_output_port(ctx, stderr, SEXP_FALSE); + sexp_print_exception(ctx, res, err); exit_failure(); } return res; @@ -63,7 +65,7 @@ void run_main (int argc, char **argv) { ctx = sexp_make_eval_context(NULL, NULL, NULL); sexp_gc_preserve2(ctx, str, args); env = sexp_context_env(ctx); - out = sexp_eval_string(ctx, "(current-output-port)", env); + out = SEXP_FALSE; args = SEXP_NULL; /* parse options */ @@ -73,9 +75,11 @@ void run_main (int argc, char **argv) { case 'p': if (! init_loaded++) check_exception(ctx, sexp_load_standard_env(ctx, env, SEXP_FIVE)); - check_exception(ctx, sexp_read_from_string(ctx, argv[i+1])); - check_exception(ctx, sexp_eval(ctx, res, env)); + res = check_exception(ctx, sexp_read_from_string(ctx, argv[i+1])); + res = check_exception(ctx, sexp_eval(ctx, res, env)); if (argv[i][1] == 'p') { + if (! sexp_oportp(out)) + out = sexp_eval_string(ctx, "(current-output-port)", env); sexp_write(ctx, res, out); sexp_write_char(ctx, '\n', out); }