Printing results as Lisp quoted strings is really unhelpful for shell
scripts.
(loop (let ((form (read in nil token)))
(when (eq form token) (return))
(funcall func form)))))
(loop (let ((form (read in nil token)))
(when (eq form token) (return))
(funcall func form)))))
+ (princ-form (form)
+ (format t "~@[~{~A~^ ~}~%~]"
+ (multiple-value-list (eval form))))
(prin1-form (form)
(format t "~@[~{~S~^ ~}~%~]"
(multiple-value-list (eval form)))))
(prin1-form (form)
(format t "~@[~{~S~^ ~}~%~]"
(multiple-value-list (eval form)))))
(#\! (push (lambda ()
(foreach-form #'eval rest))
list))
(#\! (push (lambda ()
(foreach-form #'eval rest))
list))
+ (#\= (push (lambda ()
+ (foreach-form #'princ-form rest))
+ list))
(#\? (push (lambda ()
(foreach-form #'prin1-form rest))
list))
(#\? (push (lambda ()
(foreach-form #'prin1-form rest))
list))
.IR form ]
.RB [ \-l
.IR file ]
.IR form ]
.RB [ \-l
.IR file ]
+.RB [ \-p
+.IR form ]
+.if !t \{\
+.br
+ \c
+.\}
.RB [ \-\- ]
.RI [ arguments
\*(..]
.RB [ \-\- ]
.RI [ arguments
\*(..]
.I expr
and print the resulting value(s)
to standard output
.I expr
and print the resulting value(s)
to standard output
+(with
+.B *print-escape*
+true, as if by
.BR prin1 ).
If a form produces multiple values,
they are printed on a single line,
.BR prin1 ).
If a form produces multiple values,
they are printed on a single line,
to execute in
.I eval
mode.
to execute in
.I eval
mode.
+See also
+.RB ` \-p ',
+which prints with
+.B *print-escape*
+false.
.
.TP
.BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
.
.TP
.BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
from the configuration file(s).
.
.TP
from the configuration file(s).
.
.TP
+.BI "\-p" "\fR, " "\-\-print-expression=" expr
+Evaluate the expression(s)
+.I expr
+and print the resulting value(s)
+to standard output
+(with
+.B *print-escape*
+false, as if by
+.BR princ ).
+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.
+See also
+.RB ` \-d ',
+which prints with
+.B *print-escape*
+true.
+.
+.TP
.BR "\-q" ", " "\-\-quiet"
Don't print warning messages.
This option may be repeated:
.BR "\-q" ", " "\-\-quiet"
Don't print warning messages.
This option may be repeated:
The
.RB ` \-d ',
.RB ` \-e ',
The
.RB ` \-d ',
.RB ` \-e ',
options may only be given on the command-line itself,
not following a
.RB `@ RUNLISP: '
options may only be given on the command-line itself,
not following a
.RB `@ RUNLISP: '
If the command line contains any of
.RB ` \-d ',
.RB ` \-e ',
If the command line contains any of
.RB ` \-d ',
.RB ` \-e ',
then
.B runlisp
treats all of its positional arguments as
then
.B runlisp
treats all of its positional arguments as
mode, so it's too late for
.RB ` \-d ',
.RB ` \-e ',
mode, so it's too late for
.RB ` \-d ',
.RB ` \-e ',
too.
.PP
(This feature allows scripts to provide options even if they use
too.
.PP
(This feature allows scripts to provide options even if they use
fprintf(fp, "\
usage:\n\
%s [OPTIONS] [--] SCRIPT [ARGUMENTS ...]\n\
fprintf(fp, "\
usage:\n\
%s [OPTIONS] [--] SCRIPT [ARGUMENTS ...]\n\
- %s [OPTIONS] [-e EXPR] [-d EXPR] [-l FILE] [--] [ARGUMENTS ...]\n\
+ %s [OPTIONS] [-e EXPR] [-d EXPR] [-p EXPR] [-l FILE]\n\
+ [--] [ARGUMENTS ...]\n\
OPTIONS:\n\
[-CDEnqv] [+DEn] [-L SYS,SYS,...] [-c CONF] [-o [SECT:]VAR=VAL]\n",
progname, progname);
OPTIONS:\n\
[-CDEnqv] [+DEn] [-L SYS,SYS,...] [-c CONF] [-o [SECT:]VAR=VAL]\n",
progname, progname);
Evaluation mode:\n\
-d, --dump-expression=EXPR Print (`prin1') EXPR (repeatable).\n\
-e, --evaluate-expression=EXPR Evaluate EXPR for effect (repeatable).\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",
+ -l, --load-file=FILE Load FILE (repeatable).\n\
+ -p, --print-expression=EXPR Print (`princ') EXPR (repeatable).\n",
optarg = 0; optind = 0; optprog = (/*unconst*/ char *)progname;
for (;;) {
optarg = 0; optind = 0; optprog = (/*unconst*/ char *)progname;
for (;;) {
- i = mdwopt(argc, argv, "+hVD+E+L:c:d:e:l:n+o:qv", opts, 0, 0,
+ i = mdwopt(argc, argv, "+hVD+E+L:c:d:e:l:n+o:p:qv", opts, 0, 0,
OPTF_NEGATION | OPTF_NOPROGNAME);
if (i < 0) break;
switch (i) {
OPTF_NEGATION | OPTF_NOPROGNAME);
if (i < 0) break;
switch (i) {
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 '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;
case 'q': CMDL; if (verbose) verbose--; break;
case 'v': CMDL; verbose++; break;
default: flags |= AF_BOGUS; break;
(defvar runlisp-test:bar "stoat!")' \
-d runlisp-test:foo \
-d runlisp-test:bar \
(defvar runlisp-test:bar "stoat!")' \
-d runlisp-test:foo \
-d runlisp-test:bar \
-e '(incf runlisp-test:foo)' \
-l script.lisp \
-d runlisp-test:foo \
-- -e one two three],,
[1
"stoat!"
-e '(incf runlisp-test:foo)' \
-l script.lisp \
-d runlisp-test:foo \
-- -e one two three],,
[1
"stoat!"
And we're running the script...
Command-line arguments: ("-e" "one" "two" "three")
Symbols in package `COMMON-LISP-USER': ()
And we're running the script...
Command-line arguments: ("-e" "one" "two" "three")
Symbols in package `COMMON-LISP-USER': ()