mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
Disable *COMPILE-VERBOSE* and *LOAD-VERBOSE* for --script
Scripts using COMPILE or LOAD, either directly or through third party systems, pollute the standard output with messages unrelated to the script itself. This is undesirable (to quote a comment in toplevel.lisp, "scripts don't need to be stylish or fast, but silence is usually a desirable quality") and can cause bugs when the output of a script is processed through a UNIX pipe by a program expecting to get output and not verbose diagnostic messages. Problem originally signaled by Hraban Luyat <hraban@0brg.net>.
This commit is contained in:
parent
3343f31d8f
commit
3b3998bc73
|
|
@ -338,6 +338,11 @@ broken pipe) on either standard input, standard output, or standard
|
|||
error, the script silently exits with code 0. This allows e.g. safely
|
||||
piping output from SBCL to @code{head -n1} or similar.
|
||||
|
||||
Additionally, the option sets @code{*compile-verbose*} and
|
||||
@code{*load-verbose*} to @code{nil} while loading the file to avoid
|
||||
potentially verbose diagnostic messages printed on the standard
|
||||
output.
|
||||
|
||||
@end table
|
||||
|
||||
@node Initialization Files
|
||||
|
|
|
|||
|
|
@ -381,7 +381,13 @@ any non-negative real number."
|
|||
(*debug-io* (make-two-way-stream *stdin* *stderr*))
|
||||
(*standard-input* *stdin*)
|
||||
(*standard-output* *stdout*)
|
||||
(*error-output* *stderr*))
|
||||
(*error-output* *stderr*)
|
||||
;; Compile/load messages from the language implementation
|
||||
;; are not really what one would expect from a script. And
|
||||
;; these messages are printed on stdout interfere when
|
||||
;; scripts are used as part as a UNIX pipeline.
|
||||
(*compile-verbose* nil)
|
||||
(*load-verbose* nil))
|
||||
(load stream :verbose nil :print nil)))))
|
||||
(handling-end-of-the-world
|
||||
(if (eq t script)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ echo '(exit :code 7)' > $tmpscript
|
|||
run_sbcl --script $tmpscript
|
||||
check_status_maybe_lose "--script exit status from EXIT" $? 7 "(status good)"
|
||||
|
||||
echo '(when (and (null *load-verbose*) (null *compile-verbose*)) (exit :code 7))' > $tmpscript
|
||||
run_sbcl --script $tmpscript
|
||||
check_status_maybe_lose "--script verbosity" $? 7 "(silent)"
|
||||
|
||||
echo '(error "oops")' > $tmpscript
|
||||
run_sbcl --script $tmpscript 1> $tmpout 2> $tmperr
|
||||
check_status_maybe_lose "--script exit status from ERROR" $? 1 "(error implies 1)"
|
||||
|
|
|
|||
Loading…
Reference in a new issue