init file: add --no-userinit

and add --noinform that was missing in Clingon options.

Move the useful load-without-shebang in utils.lisp, now available for
all systems.

"make" alone calls make build
This commit is contained in:
vindarel 2023-05-04 16:53:40 +02:00
parent f7a4f06335
commit b23214917c
8 changed files with 98 additions and 33 deletions

View file

@ -8,33 +8,6 @@
Hash-table: file name (sans extension) -> file content (string).
The name is case-insensitive (it's easier for typing things in the terminal).")
(defun maybe-ignore-shebang (in)
"If this file starts with #!, delete the shebang line,
so we can LOAD the file.
Return: a stream (it is LOADable)."
;; thanks Roswell for the trick.
(let ((first-line (read-line in)))
(make-concatenated-stream
;; remove shebang:
(make-string-input-stream
(format nil "~a"
(if (str:starts-with-p "#!" first-line)
""
first-line)))
;; rest of the file:
in)))
(defun load-without-shebang (file)
"LOAD this file, but exclude the first line if it is a shebang line."
(with-open-file (file-stream file)
(load
(maybe-ignore-shebang file-stream))))
(defun has-shebang (file)
"Return T if the first line of this file is a shell shebang line (starts with #!)."
(with-open-file (s file)
(str:starts-with-p "#!" (read-line s))))
;; eval
(defun wrap-user-code (s)
"Wrap this user code to handle common conditions, such as a C-c C-c to quit gracefully."
@ -124,6 +97,16 @@
:long-name "scripts"
:short-name #\z
:key :scripts)
(clingon:make-option
:flag
:description "Don't load the ~/.cielrc init file at start-up (for the CIEL terminal REPL)."
:long-name "no-userinit"
:key :no-userinit)
(clingon:make-option
:flag
:description "Don't print the welcome banner."
:long-name "noinform"
:key :noinform)
))
#+(or)
@ -259,6 +242,8 @@
;; default: run CIEL's REPL.
(t
;; XXX: maybe pass all CLI options here, don't re-read them in the repl function.
;; (which was the old way).
(sbcli::repl)))
(error (c)