--eval + --script output polluted by banner

Bug #2089235 reported by Guilherme Janczak
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

If I have a hello.lisp with these contents (delimited with markdown for convenience):
```lisp
(format t "Hello from script~%")
```

And I run sbcl as follows:
```sh
sbcl --eval '(format t "Hello from eval~%")' --script hello.lisp
```

The output is polluted by a banner:
```plain
This is SBCL 2.4.8.openbsd.sbcl-2.4.8, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
Hello from eval
Hello from script
```

Instead, it should be:
```plain
Hello from eval
Hello from script
```

At it currently stands, --eval in combination with --script is only useful in programs where stdout is used purely for human consumption.

SBCL version:
SBCL 2.4.8.openbsd.sbcl-2.4.8
uname -a:
OpenBSD jan-z87-obsd 7.6 GENERIC.MP#338 amd64

Revision history for this message
Guilherme Janczak (guijan) wrote :

Ahh, though --eval reenables the banner when used in combination with --script, --noinform disables it again.

```console
λ sbcl --noinform --eval '(format t "Hello from eval~%")' --script /tmp/hello.lisp
Hello from eval
Hello from script
```

Revision history for this message
Richard M Kreuter (kreuter) wrote :

By coincidence, I was just looking at --script processing today, and wondering if people mix --load, --eval, and --script. May I ask why you're interested in using both? If the script needs to evaluate an expression supplied on the command line before doing anything else, it can EVAL some element of SB-EXT:*POSIX-ARGV*, for example.

(The ability to combine --script with other flags is unnecessary for the "shbang line" use case, and makes the de facto argv grammar & semantics confusing, as you've found. IMO it would have been simpler had the rules been that --script had to be argv[1] with a mandatory filename, i.e., if --script had been mutually exclusive with all the other flags.)

Revision history for this message
Guilherme Janczak (guijan) wrote :

I'm writing a program that is like `cl-launch` but it's faster and more portable. I have it launching sbcl with quicklisp and printing "Hello, world!" on my desktop in ~20ms after quicklisp is cached and it's not even caching the script itself because I haven't written any caching code, a Python equivalent is <10ms, and cl-launch takes 500ms or more.

--load and --eval are useful for passing a script to tell it to load quicklisp. With --eval you can save 1 file access which is important on really slow machines, a modern hard disk already takes 20ms for uncached file reads under no load, older ones take hundreds of ms and some operating systems have slow filesystem access that makes it even worse.

Revision history for this message
Richard M Kreuter (kreuter) wrote :

Thanks for the explanation.

Since your usage requires constructing an SBCL command line anyway, would it make any difference if your argv explicitly included the flags that --script implies and and ran the script using --eval? Something like

```
sbcl --noinform --no-userinit --no-sysinit --disable-debugger [your --eval & --load flags...] --eval '(sb-ext:run-script (second sb-ext:*posix-argv*))' --quit --end-toplevel-options your-script-file [arguments...]
```

where SB-EXT:RUN-SCRIPT would be an operator that loads a file in a dynamic environment like the one --script configures?

Revision history for this message
Guilherme Janczak (guijan) wrote :

It wouldn't make a difference.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.