From 05a9f820c6355e27bca8a87cd6a235bedcb872de Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 15 May 2021 14:45:20 +0100 Subject: [PATCH] runlisp.c, etc.: Rename `-p' to `-d'. COMPAT This is to make way for a new `-p' option which works like `princ'. --- runlisp.1.in | 54 +++++++++++++++++++++++++++--------------------------- runlisp.c | 11 ++++++----- tests.at | 20 ++++++++++---------- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/runlisp.1.in b/runlisp.1.in index 119c4e0..35378d4 100644 --- a/runlisp.1.in +++ b/runlisp.1.in @@ -58,12 +58,12 @@ runlisp \- run Common Lisp programs as scripts .br .B runlisp .RI [ options ] +.RB [ \-d +.IR form ] .RB [ \-e .IR form ] .RB [ \-l .IR file ] -.RB [ \-p -.IR form ] .RB [ \-\- ] .RI [ arguments \*(..] @@ -199,6 +199,25 @@ All of the files are expected to be as described in .BR runlisp.conf (5). . .TP +.BI "\-d" "\fR, " "\-\-dump-expression=" expr +Evaluate the expression(s) +.I expr +and print the resulting value(s) +to standard output +(as if by +.BR prin1 ). +If a form produces multiple values, +they are printed on a single line, +separated by a single space character; +if a form produces no values at all, +then nothing is printed \(en not even a newline character. +This option causes +.B runlisp +to execute in +.I eval +mode. +. +.TP .BI "\-e" "\fR, " "\-\-evaluate-expression=" expr Evaluate the expression(s) .I expr @@ -247,25 +266,6 @@ and overrides any similarly named setting from the configuration file(s). . .TP -.BI "\-p" "\fR, " "\-\-print-expressin=" expr -Evaluate the expression(s) -.I expr -and print the resulting value(s) -to standard output -(as if by -.BR prin1 ). -If a form produces multiple values, -they are printed on a single line, -separated by a single space character; -if a form produces no values at all, -then nothing is printed \(en not even a newline character. -This option causes -.B runlisp -to execute in -.I eval -mode. -. -.TP .BR "\-q" ", " "\-\-quiet" Don't print warning messages. This option may be repeated: @@ -290,10 +290,10 @@ Higher verbosity levels print informational and debugging messages. . .PP The +.RB ` \-d ', .RB ` \-e ', -.RB ` \-l ', and -.RB ` \-p ' +.RB ` \-l ' options may only be given on the command-line itself, not following a .RB `@ RUNLISP: ' @@ -323,10 +323,10 @@ though the boundary may be marked explicitly using .RB ` \-\- ' if desired. If the command line contains any of +.RB ` \-d ', .RB ` \-e ', -.RB ` \-l ', or -.RB ` \-p ', +.RB ` \-l ', then .B runlisp treats all of its positional arguments as @@ -422,10 +422,10 @@ and is now committed to .I script mode, so it's too late for +.RB ` \-d ', .RB ` \-e ', -.RB ` \-l ', and -.RB ` \-p ' +.RB ` \-l ' too. .PP (This feature allows scripts to provide options even if they use diff --git a/runlisp.c b/runlisp.c index 5cd1320..4e13663 100644 --- a/runlisp.c +++ b/runlisp.c @@ -199,7 +199,7 @@ static void usage(FILE *fp) fprintf(fp, "\ usage:\n\ %s [OPTIONS] [--] SCRIPT [ARGUMENTS ...]\n\ - %s [OPTIONS] [-e EXPR] [-p EXPR] [-l FILE] [--] [ARGUMENTS ...]\n\ + %s [OPTIONS] [-e EXPR] [-d EXPR] [-l FILE] [--] [ARGUMENTS ...]\n\ OPTIONS:\n\ [-CDEnqv] [+DEn] [-L SYS,SYS,...] [-c CONF] [-o [SECT:]VAR=VAL]\n", progname, progname); @@ -228,9 +228,9 @@ Lisp implementation selection:\n\ -L, --accept-lisp=SYS,SYS,... Only use the listed Lisp systems.\n\ \n\ Evaluation mode:\n\ + -d, --dump-expression=EXPR Print (`prin1') EXPR (repeatable).\n\ -e, --evaluate-expression=EXPR Evaluate EXPR for effect (repeatable).\n\ - -l, --load-file=FILE Load FILE (repeatable).\n\ - -p, --print-expression=EXPR Print (`prin1') EXPR (repeatable).\n", + -l, --load-file=FILE Load FILE (repeatable).\n", fp); } @@ -257,6 +257,7 @@ static void parse_options(int argc, char *argv[]) { "command-line-only", OPTF_NEGATE, 0, 'E' }, { "accept-lisp", OPTF_ARGREQ, 0, 'L' }, { "config-file", OPTF_ARGREQ, 0, 'c' }, + { "dump-expression", OPTF_ARGREQ, 0, 'd' }, { "evaluate-expression", OPTF_ARGREQ, 0, 'e' }, { "load-file", OPTF_ARGREQ, 0, 'l' }, { "dry-run", OPTF_NEGATE, 0, 'n' }, @@ -280,7 +281,7 @@ static void parse_options(int argc, char *argv[]) optarg = 0; optind = 0; optprog = (/*unconst*/ char *)progname; for (;;) { - i = mdwopt(argc, argv, "+hVD+E+L:c:e:l:n+o:p:qv", opts, 0, 0, + i = mdwopt(argc, argv, "+hVD+E+L:c:d:e:l:n+o:qv", opts, 0, 0, OPTF_NEGATION | OPTF_NOPROGNAME); if (i < 0) break; switch (i) { @@ -293,11 +294,11 @@ static void parse_options(int argc, char *argv[]) offsetof(struct lispsys, next_accept)); break; case 'c': CMDL; read_config_path(optarg, 0); flags |= AF_SETCONF; break; + case 'd': CMDL; push_eval_op('?', optarg); break; case 'e': CMDL; push_eval_op('!', optarg); break; case 'l': CMDL; push_eval_op('<', optarg); break; FLAGOPT('n', AF_DRYRUN, { CMDL; }); case 'o': CMDL; if (set_config_var(optarg)) flags |= AF_BOGUS; break; - case 'p': CMDL; push_eval_op('?', optarg); break; case 'q': CMDL; if (verbose) verbose--; break; case 'v': CMDL; verbose++; break; default: flags |= AF_BOGUS; break; diff --git a/tests.at b/tests.at index 867ae5e..73b13ae 100644 --- a/tests.at +++ b/tests.at @@ -210,7 +210,7 @@ AT_CHECK([RUNLISP_PATH -e '(format t "Just another Lisp hacker!~%")'],, ## The `:runlisp-script' keyword should /not/ be in `*features*'. traceon -AT_CHECK([RUNLISP_PATH -p '(find :runlisp-script *features*)'],, [NIL +AT_CHECK([RUNLISP_PATH -d '(find :runlisp-script *features*)'],, [NIL ]) ## Check a mixture of all the kinds of evaluation. We'll need a stunt script @@ -232,11 +232,11 @@ AT_CHECK([RUNLISP_PATH \ -e '(defpackage [#:]runlisp-test (:export [#:]foo [#:]bar)) (defvar runlisp-test:foo 1) (defvar runlisp-test:bar "stoat!")' \ - -p runlisp-test:foo \ - -p runlisp-test:bar \ + -d runlisp-test:foo \ + -d runlisp-test:bar \ -e '(incf runlisp-test:foo)' \ -l script.lisp \ - -p runlisp-test:foo \ + -d runlisp-test:foo \ -- -e one two three],, [1 "stoat!" @@ -280,9 +280,9 @@ echo Secondary Lisp = $lisp1 echo Bad Lisp = $badlisp ## Check that our selection worked. -AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0 -p 'WHICH_LISP'],, ["$lisp0"NL]) -AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1 -p 'WHICH_LISP'],, ["$lisp1"NL]) -AT_CHECK([RUNLISP_PATH -L$badlisp -p 'WHICH_LISP'], [127],, +AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0 -d 'WHICH_LISP'],, ["$lisp0"NL]) +AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1 -d 'WHICH_LISP'],, ["$lisp1"NL]) +AT_CHECK([RUNLISP_PATH -L$badlisp -d 'WHICH_LISP'], [127],, [runlisp: no acceptable Lisp systems found[]NL]) ## Unset all of the user preference mechanisms. @@ -291,9 +291,9 @@ mkdir HOME config HOME=$here/HOME XDG_CONFIG_HOME=$here/config; export HOME XDG_CONFIG_HOME ## We generally take the first one listed that exists. -AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0,$lisp1 -p 'WHICH_LISP'],, ["$lisp0"NL]) -AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1,$lisp0 -p 'WHICH_LISP'],, ["$lisp1"NL]) -AT_CHECK_UNQUOTED([RUNLISP_PATH -L$badlisp,$lisp0,$lisp1 -p 'WHICH_LISP'],, +AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0,$lisp1 -d 'WHICH_LISP'],, ["$lisp0"NL]) +AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1,$lisp0 -d 'WHICH_LISP'],, ["$lisp1"NL]) +AT_CHECK_UNQUOTED([RUNLISP_PATH -L$badlisp,$lisp0,$lisp1 -d 'WHICH_LISP'],, ["$lisp0"NL]) ## Check parsing of embedded options. -- 2.11.0