diff options
-rw-r--r-- | txr.1 | 21 | ||||
-rw-r--r-- | txr.c | 7 |
2 files changed, 26 insertions, 2 deletions
@@ -33101,6 +33101,27 @@ processing; they will be processed in a later garbage collection pass. .coNP Variable @ self-path .desc This variable holds the invocation path name of the \*(TX program. +The value of +.code self-path +when \*(TL expressions are being evaluated in command line arguments +is the string +.strn cmdline-expr . +The value of +.code self-path +when a \*(TX query is supplied on the command line via the +.code -c +command line option is the string +.strn cmdline . + +Note that for programs read from a file, +.code self-path +holds the resolved name, and not the invocation name. For instance if +.code foo.tl +is invoked using the name +.codn foo , +whereby \*(TX infers the suffix, then +.code self-path +holds the suffixed name. .coNP Variable @ stdlib The @@ -398,6 +398,7 @@ int txr_main(int argc, char **argv) val parse_stream = std_input; val txr_lisp_p = nil; val enter_repl = nil; + val self_path_s = intern(lit("self-path"), user_package); list_collect_decl(arg_list, arg_tail); setvbuf(stderr, 0, _IOLBF, 0); @@ -581,6 +582,7 @@ int txr_main(int argc, char **argv) spec_file = arg; break; case 'e': + reg_varl(self_path_s, lit("cmdline-expr")); eval_intrinsic(lisp_parse(arg, std_error, colon_k, lit("cmdline-expr"), colon_k), make_env(bindings, nil, nil)); @@ -595,6 +597,7 @@ int txr_main(int argc, char **argv) if3(c_chr(opt) == 'P', pprinl, tprint)); + reg_varl(self_path_s, lit("cmdline-expr")); pf(eval_intrinsic(lisp_parse(arg, std_error, colon_k, lit("cmdline-expr"), colon_k), make_env(bindings, nil, nil)), std_output); @@ -716,6 +719,7 @@ int txr_main(int argc, char **argv) } reg_var(intern(lit("*args*"), user_package), arg_list); + reg_varl(intern(lit("self-path"), user_package), spec_file_str); if (!txr_lisp_p) { @@ -736,8 +740,7 @@ int txr_main(int argc, char **argv) format(std_error, lit("bindings:\n~s\n"), bindings, nao); } - reg_varl(intern(lit("*self-path*"), user_package), spec_file_str); - reg_var(intern(lit("self-path"), user_package), spec_file_str); + reg_var(intern(lit("*self-path*"), user_package), spec_file_str); { val result = extract(spec, arg_list, bindings); |