aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-10-24 19:46:02 -0300
committerEuAndreh <eu@euandre.org>2022-10-24 19:46:02 -0300
commit304657029cd02fb33d9ec432dbad9348d7493541 (patch)
tree7a1c8c6b30a45397831001884780dcd0dd5ee7ff
parentbin/cl: Reorder SBCL non-verbose argument (diff)
downloaddotfiles-304657029cd02fb33d9ec432dbad9348d7493541.tar.gz
dotfiles-304657029cd02fb33d9ec432dbad9348d7493541.tar.xz
bin/cl: Allow giving "-- --option" to the underlying Lisp command
-rwxr-xr-xbin/cl38
1 files changed, 24 insertions, 14 deletions
diff --git a/bin/cl b/bin/cl
index 245c0db..cadc9d5 100755
--- a/bin/cl
+++ b/bin/cl
@@ -41,7 +41,7 @@ sbcl
usage() {
cat <<-'EOF'
Usage:
- cl [-e EXP] [-f FILE] [-p] [-M IMAGE] [-I IMPL] [-n] [-v] [FILE...]
+ cl [-e EXP] [-f FILE] [-p] [-M IMAGE] [-I IMPL] [-n] [-v] [FILE...] [-- LISP_OPTIONS]
cl -l
cl -h
EOF
@@ -52,17 +52,18 @@ help() {
Options:
- -e EXP an sexp to be evaluated (can be given more than once)
- -f FILE a file to be evaluated (can be given more than once)
- -p print the value of the last given expression
- -M IMAGE load the given Lisp image
- -I IMPL use the given implementation (default: $LISP_CLI_IMPL)
- -n skip loading the implementation's init file
- -v verbose mode
- -l list the known types of implementations
- -h, --help show this message
+ -e EXP an sexp to be evaluated (can be given more than once)
+ -f FILE a file to be evaluated (can be given more than once)
+ -p print the value of the last given expression
+ -M IMAGE load the given Lisp image
+ -I IMPL use the given implementation (default: $LISP_CLI_IMPL)
+ -n skip loading the implementation's init file
+ -v verbose mode
+ -l list the known types of implementations
+ -h, --help show this message
- FILE the file to be executed as a script
+ FILE the file to be executed as a script
+ LISP_OPTIONS options to be forwarrded to the underlying Lisp command
Lauch the desired Lisp implementation, properly adapting the given
@@ -177,12 +178,21 @@ while getopts 'e:f:pM:I:nvlh' flag; do
done
shift $((OPTIND - 1))
+PRESERVE_ARGS=false
INTERACTIVE=true
for f in "$@"; do
+ if [ "$f" = '--' ]; then
+ PRESERVE_ARGS=true
+ shift
+ break
+ fi
INTERACTIVE=false
escape_name "$f" >> "$SCRIPT"
done
-set --
+
+if [ "$PRESERVE_ARGS" = false ]; then
+ set --
+fi
MAIN="$(mkstemp)"
if [ "$NO_RC" = false ] && [ -e "$LISP_CLI_RC" ]; then
@@ -233,7 +243,7 @@ case "$IMPL" in
exit 4
;;
clisp)
- set -- -ansi -i "$MAIN"
+ set -- -ansi -i "$MAIN" "$@"
if [ -n "$IMAGE" ]; then
set -- "$@" -M "$IMAGE"
fi
@@ -260,7 +270,7 @@ case "$IMPL" in
exit 4
;;
sbcl)
- set -- --load "$MAIN"
+ set -- --load "$MAIN" "$@"
if [ -n "$IMAGE" ]; then
# The '--core' "C runtime option" must appear before the
# other "Lisp options", such as '--load'.