diff options
-rw-r--r-- | txr.1 | 28 | ||||
-rw-r--r-- | txr.c | 8 |
2 files changed, 33 insertions, 3 deletions
@@ -78979,7 +78979,9 @@ smaller than 32767 bytes are strongly discouraged. .SS* Modularization .coNP Variable @ self-path .desc -This variable holds the invocation pathname of the \*(TX program. +This variable holds the invocation pathname of a \*(TX program +that was specified on the command line. + The value of .code self-path when \*(TL expressions are being evaluated in command-line arguments @@ -78992,6 +78994,21 @@ when a \*(TX query is supplied on the command line via the command-line option is the string .strn cmdline . +When a file is being compiled using the +.code --compile +option, the value of +.code self-path +is the source file path. + +When the interactive listener is entered, +.code self-path +is set to the value +.strn listener , +even if prior to that, a file was compiled +or executed, for which +.code self-path +had been set to the name of that file. + Note that for programs read from a file, .code self-path holds the resolved name, and not the invocation name. For instance if @@ -79002,6 +79019,15 @@ whereby \*(TX infers the suffix, then .code self-path holds the suffixed name. +Note that the functions +.codn load , +.code compile-file +and +.code compile-update-file +have no effect on the value of +.code self-path. +The variable is set strictly by command line processing. + .coNP Variable @ stdlib .desc The @@ -82,6 +82,7 @@ int opt_compat; int opt_dbg_expansion; int opt_free_all; val stdlib_path; +val self_path_s; #if HAVE_FORK_STUFF #define IF_HAVE_FORK_STUFF(THEN, ELSE) THEN @@ -455,6 +456,8 @@ static void do_compile_opt(val arg) source = sub_str(source, zero, col_pos); } + reg_varl(self_path_s, source); + funcall2(compile_update_file, source, target); } @@ -572,7 +575,6 @@ int txr_main(int argc, char **argv) val txr_lisp_p = nil; val enter_repl = nil; val args_s = intern(lit("*args*"), user_package); - val self_path_s = intern(lit("self-path"), user_package); val compat_var = lit("TXR_COMPAT"); val compat_val = getenv_wrap(compat_var); val orig_args = nil, ref_arg_list = nil; @@ -582,6 +584,8 @@ int txr_main(int argc, char **argv) static char alt_args_buf[128 + 7] = "@(txr):", *alt_args = alt_args_buf + 7; + self_path_s = intern(lit("self-path"), user_package); + if (ends_with(lit("lisp" EXE_SUFF), prog_path, nil, nil)) txr_lisp_p = t; else if (ends_with(lit("vm" EXE_SUFF), prog_path, nil, nil)) @@ -1269,7 +1273,7 @@ repl: "due to environment variable.\n"), num(opt_compat), nao); reg_var(args_s, or2(orig_args, arg_list)); - reg_varl(intern(lit("self-path"), user_package), lit("listener")); + reg_varl(self_path_s, lit("listener")); env_vbind(dyn_env, package_s, opt_compat && opt_compat <= 190 ? user_package : public_package); env_vbind(dyn_env, load_recursive_s, nil); |