aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/cl302
-rwxr-xr-xbin/li107
l---------opt/bin-dirs/src1
3 files changed, 1 insertions, 409 deletions
diff --git a/bin/cl b/bin/cl
deleted file mode 100755
index dd690bb..0000000
--- a/bin/cl
+++ /dev/null
@@ -1,302 +0,0 @@
-#!/bin/sh
-set -eu
-
-
-escape_name() {
- printf '%s' "$1" |
- sed 's|"|\\"|g' |
- printf '(load "%s")\n' "$(cat -)"
-}
-
-
-IMPLEMENTATIONS='
-abcl
-allegro
-clasp
-clisp
-clozure
-cmucl
-ecl
-jscl
-mkcl
-sbcl
-'
-
-usage() {
- cat <<-'EOF'
- Usage:
- cl [-e EXP] [-f FILE] [-p] [-M IMAGE] [-I IMPL] [-n] [-v] [FILE...] [-- LISP_OPTIONS]
- cl -l
- cl -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
-
- Options:
- -e EXP an sexp to be evaluated (can be given more than once)
- -E EXP an sexp to be executed as a script
- -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
- LISP_OPTIONS options to be forwarrded to the underlying Lisp command
-
-
- Lauch the desired Lisp implementation, properly adapting the given
- CLI options.
-
- When the implementation is not explicited on the command line, and
- the $LISP_CLI_IMPL environment variable in unset, implementations are
- searched for alphabetically in $PATH, untill one is found, otherwise
- an error is emitted.
-
- The supported implementations are:
- EOF
-
-
- for i in $IMPLEMENTATIONS; do
- printf -- '- %s\n' "$i"
- done
-
- cat <<-'EOF'
-
-
- Examples:
-
- Launch CLISP REPL, when $LISP_CLI_IMPL is set to 'clisp':
-
- $ cl
-
-
- Lauch SBCL REPL, with the given Lisp image loaded, skipping the
- loading of the '.sbclrc' file:
-
- $ cl -n -Isbcl sbcl.image
-
-
- Run file1.lisp with ABCL:
-
- $ cl -Iabcl file1.lisp
-
-
- Process STDIN:
-
- $ cat <<-EOS > process.lisp
-
- EOS
- $ cat f1.txt f2.txt | cl -p process.lisp
-
-
- Print a value on all types of implementations:
-
- $ for i in `cl -l`; do cl -I$i -pe 'call-arguments-list'; done
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-SCRIPT="$(mkstemp)"
-trap 'rm -f "$SCRIPT"' EXIT
-
-NO_RC=false
-LISP_CLI_RC="${XDG_CONFIG_HOME:-$HOME/.config}/lisp-cli/init.lisp"
-VERBOSE=false
-IMAGE=''
-IMPL="${LISP_CLI_IMPL:-}"
-INTERACTIVE=true
-while getopts 'e:E:f:pM:I:nvlh' flag; do
- case "$flag" in
- e)
- printf '%s\n' "$OPTARG" >> "$SCRIPT"
- ;;
- E)
- printf '%s\n' "$OPTARG" >> "$SCRIPT"
- INTERACTIVE=false
- ;;
- f)
- escape_name "$OPTARG" >> "$SCRIPT"
- ;;
- M)
- IMAGE="$OPTARG"
- ;;
- I)
- IMPL="$OPTARG"
- ;;
- n)
- NO_RC=true
- ;;
- v)
- VERBOSE=true
- ;;
- l)
- for i in $IMPLEMENTATIONS; do
- printf '%s\n' "$i"
- done
- exit
- ;;
- h)
- usage
- help
- exit
- ;;
- *)
- usage >&2
- exit 2
- ;;
- esac
-done
-
-shift $((OPTIND - 2))
-if [ "$1" != '--' ]; then
- shift
-fi
-
-PRESERVE_ARGS=false
-for f in "$@"; do
- if [ "$f" = '--' ]; then
- PRESERVE_ARGS=true
- shift
- break
- fi
- INTERACTIVE=false
- escape_name "$f" >> "$SCRIPT"
-done
-
-if [ "$PRESERVE_ARGS" = false ]; then
- set --
-fi
-
-MAIN="$(mkstemp)"
-trap 'rm -f "$MAIN"' EXIT
-if [ "$NO_RC" = false ] && [ -e "$LISP_CLI_RC" ]; then
- escape_name "$LISP_CLI_RC" > "$MAIN"
-fi
-
-if [ "$INTERACTIVE" = true ]; then
- escape_name "$SCRIPT" >> "$MAIN"
-else
- cat <<-EOF >> "$MAIN"
- (handler-case
- (progn
- (load "$SCRIPT"
- :verbose nil
- :print nil)
- (uiop:quit 0))
- (error (e)
- (format *error-output* "~&~%error: ~a~%" e)
- (uiop:quit 1)))
- EOF
-fi
-
-if [ -z "$IMPL" ]; then
- for i in $IMPLEMENTATIONS; do
- if command -v "$i" > /dev/null; then
- IMPL="$i"
- break
- fi
- done
- if [ -z "$IMPL" ]; then
- printf "Could not find any implementation in \$PATH.\n" >&2
- exit 2
- fi
-fi
-
-
-case "$IMPL" in
- abcl)
- exit 4
- ;;
- allegro)
- exit 4
- ;;
- clasp)
- exit 4
- ;;
- clisp)
- set -- -ansi -i "$MAIN" "$@"
- if [ -n "$IMAGE" ]; then
- set -- -M "$IMAGE" "$@"
- fi
- if [ "$NO_RC" = true ]; then
- set -- -norc "$@"
- fi
- if [ "$VERBOSE" = false ]; then
- set -- -q -q "$@"
- else
- set -x
- fi
- clisp "$@"
- ;;
- clozure)
- set -- -l "$MAIN" "$@"
- if [ -n "$IMAGE" ]; then
- set -- -I "$IMAGE" "$@"
- fi
- if [ "$NO_RC" = true ]; then
- set -- -n "$@"
- fi
- if [ "$VERBOSE" = false ]; then
- set -- -Q "$@"
- else
- set -x
- fi
- ccl "$@"
- ;;
- cmucl)
- exit 4
- ;;
- ecl)
- exit 4
- ;;
- jscl)
- exit 4
- ;;
- mkcl)
- exit 4
- ;;
- sbcl)
- set -- --load "$MAIN" "$@"
- if [ -n "$IMAGE" ]; then
- # The '--core' "C runtime option" must appear before the
- # other "Lisp options", such as '--load'.
- set -- --core "$IMAGE" "$@"
- fi
- if [ "$NO_RC" = true ]; then
- set -- --no-sysinit --no-userinit "$@"
- fi
- if [ "$VERBOSE" = false ]; then
- set -- --noinform "$@"
- else
- set -x
- fi
- sbcl "$@"
- ;;
- *)
- printf 'Unsupported implementation: "%s".\n\n' "$IMPL" >&2
- usage >&2
- exit 2
- ;;
-esac
diff --git a/bin/li b/bin/li
deleted file mode 100755
index 33f5d3a..0000000
--- a/bin/li
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
- cat <<-'EOF'
- Usage:
- li [-I IMPL ] [-v] [OPTIONS...]
- li -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
-
- Options:
- -I IMPL use the given implementation (default: $LISP_CLI_IMPL)
- -v verbose mode
- -h, --help show this message
-
- OPTIONS options to be forwarded to cl(1) (lisp-cli)
-
-
- Run the cl(1) executable with OPTIONS, but make sure an up-to-date
- image exists and load it.
-
-
- Examples:
-
- Launch a REPL from an image:
-
- $ li
-
-
- Give options to cl(1):
-
- $ li -I sbcl -e '(print 123)'
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-VERBOSE=false
-IMPL="${LISP_CLI_IMPL:-clisp}"
-while getopts ':I:vh' flag; do
- case "$flag" in
- I)
- IMPL="$OPTARG"
- ;;
- v)
- VERBOSE=true
- ;;
- h)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-if [ "${1:-}" = '--' ]; then
- shift
-fi
-
-
-IMAGE="${XDG_DATA_HOME:-$HOME/.local/share}/lisp-cli/$IMPL.image"
-BIN="$(command -v cl)"
-INIT="${XDG_CONFIG_HOME:-$HOME/.config}/lisp-cli/init.lisp"
-
-mkdir -p "$(dirname "$IMAGE")"
-
-if [ ! -e "$IMAGE" ]; then
- printf 'Bootstrapping a new "%s" image...\n' "$IMPL" >&2
- cl \
- -I "$IMPL" \
- -v \
- -e '(ql:quickload :trivial-dump-core)' \
- -E "(trivial-dump-core:dump-image \"$IMAGE\")"
-elif [ -n "$(find "$0" "$BIN" "$INIT" -newer "$IMAGE")" ]; then
- printf 'Refresh existing "%s" image...\n' "$IMPL" >&2
- cl \
- -M "$IMAGE" \
- -I "$IMPL" \
- -v \
- -e '(ql:quickload :trivial-dump-core)' \
- -E "(trivial-dump-core:dump-image \"$IMAGE\")"
-fi
-
-if [ "$VERBOSE" = true ]; then
- set -x
-fi
-exec cl -M "$IMAGE" "$@"
diff --git a/opt/bin-dirs/src b/opt/bin-dirs/src
new file mode 120000
index 0000000..9e7a0e5
--- /dev/null
+++ b/opt/bin-dirs/src
@@ -0,0 +1 @@
+/home/andreh/dev/libre/lisp-cli/src \ No newline at end of file