From 91fb2910f7cae2ebb36de0b871bc3b2e3f7a74eb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 16 Jun 2021 06:41:36 -0700 Subject: listener: new --noprofile option. * parser.c (repl): Set the rcfile variable to nil if opt_noprofile is true, to suppress reading it. * txr.c (op_noprofile): New global variable. (help): Add help text. (txr_main): Recognize noprofile option and set variable. * txr.h (opt_noprofile): Declared. * txr.1: Documented. --- parser.c | 2 +- txr.1 | 10 +++++++++- txr.c | 5 +++++ txr.h | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/parser.c b/parser.c index a6aaf096..bc01c2bf 100644 --- a/parser.c +++ b/parser.c @@ -1470,7 +1470,7 @@ val repl(val bindings, val in_stream, val out_stream, val env) val home = if3(repl_level == 1, get_home_path(), nil); val histfile = if2(home, scat2(home, lit("/.txr_history"))); const wchar_t *histfile_w = if3(home, c_str(histfile), NULL); - val rcfile = if2(home, scat2(home, lit("/.txr_profile"))); + val rcfile = if2(home && !opt_noprofile, scat2(home, lit("/.txr_profile"))); val old_sig_handler = set_sig_handler(num(SIGINT), func_n2(repl_intr)); val hist_len_var = lookup_global_var(listener_hist_len_s); val multi_line_var = lookup_global_var(listener_multi_line_p_s); diff --git a/txr.1 b/txr.1 index 1883130c..1a51cdfc 100644 --- a/txr.1 +++ b/txr.1 @@ -982,6 +982,12 @@ The re-executed image will then obtain the script name from the arguments which are passed to it and determine whether that script will run setuid. See the section SETUID/SETGID OPERATION. +.coIP --noprofile +If entering the interactive listener, suppress the reading of the +.code .txr_profile +in the home directory. See the Interactive Profile File subsection in the +INTERACTIVE LISTENER section of the manual. + .coIP --gc-debug This option enables a behavior which stresses the garbage collector with frequent garbage collection requests. The purpose is to make it more likely @@ -81246,7 +81252,9 @@ is still processed, as usual. .SS* Interactive Profile File -When the listener starts up, it looks for file called +Unless the +.code --noprofile +option has been used, when the listener starts up, it looks for file called .code .txr_profile in the user's home directory, as determined by the .code HOME diff --git a/txr.c b/txr.c index 90d6d84e..44a07843 100644 --- a/txr.c +++ b/txr.c @@ -66,6 +66,7 @@ wchar_t *progname; static const char *progname_u8; static val prog_path = nil, sysroot_path = nil; int opt_noninteractive; +int opt_noprofile; int opt_compat; int opt_dbg_expansion; val stdlib_path; @@ -156,6 +157,7 @@ static void help(void) " the following argument arg, and allows one or more\n" " copies of it to be to be embedded in the\n" " encoded arguments. See manual.\n" +"--noprofile Do not read .txr_profile when entering listener.\n" #if HAVE_FORK_STUFF "--reexec Re-execute TXR with remaining arguments.\n" #endif @@ -799,6 +801,9 @@ int txr_main(int argc, char **argv) } else if (equal(opt, lit("free-all"))) { atexit(free_all); continue; + } else if (equal(opt, lit("noprofile"))) { + opt_noprofile = 1; + continue; } else { drop_privilege(); format(std_error, lit("~a: unrecognized long option: --~a\n"), diff --git a/txr.h b/txr.h index 6df9ed69..ea5cf066 100644 --- a/txr.h +++ b/txr.h @@ -39,6 +39,7 @@ extern int opt_compat; extern int opt_debugger; extern int opt_dbg_autoload; extern int opt_dbg_expansion; +extern int opt_noprofile; extern alloc_bytes_t opt_gc_delta; extern const wchli_t *version; extern wchar_t *progname; -- cgit v1.2.3