From fe6ef8b5e2810495d9ef4620be30806857351202 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 28 Jan 2019 06:28:06 -0800 Subject: command line: support -f in Hash Bang Null Hack. * txr.c (txr_main): In processing the -f option, if there is already an input source, but its name exactly matches the argument of the -f option, then ignore the -f and its option intead of terminating with a diagnostic. This allows the user to use -f in the Null Hack to achieve the usual trick of allowing the script to take options passed through to the interpreter. * txr.1: Documented. --- txr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'txr.c') diff --git a/txr.c b/txr.c index 584ec159..be77ca1c 100644 --- a/txr.c +++ b/txr.c @@ -839,13 +839,15 @@ int txr_main(int argc, char **argv) parse_stream = make_string_byte_input_stream(specstring); break; case 'f': + spec_file = arg; if (parse_stream) { + if (equal(spec_file, spec_file_str)) + break; format(std_error, - lit("~a: -f ~a: input file has already been established\n"), - prog_string, spec_file, nao); + lit("~a: -f ~a: input source ~a has already been established\n"), + prog_string, arg, spec_file_str, nao); return EXIT_FAILURE; } - spec_file = arg; if (wcscmp(c_str(spec_file), L"-") != 0) { open_txr_file(spec_file, &txr_lisp_p, &spec_file_str, &parse_stream); simulate_setuid_setgid(parse_stream); -- cgit v1.2.3