SHCL is
- a very customizable shell made with secret alien technology, and
- an unholy union of POSIX Shell and Common Lisp.
Behold Common Lisp embedded in POSIX shell embedded in Common Lisp! Notice that the Common Lisp form embedded in the shell expression can access the lexical environment.
(let ((rld "rld")) (capture (:stdout) #$ echo Hello ,(concatenate 'string "Wo" rld) | wc -c #$)) ; => "12"
Now lay your eyes on a lisp function participating in a pipeline!
shcl> : ,(shcl/core/debug:graph-dependencies) | dot -Tpng > graph.png
SHCL is only really tested against SBCL, but it should be portable to other lisp compilers. Be aware that ECL is known to be problematic because it tries to reap child processes automatically.
First, you’ll need to install some dependencies. To start with, you’ll need Clang and libedit. There’s also some Common Lisp dependencies that need to be taken care of: SBCL, Quicklisp, and cffi-grovel. If you’re new to building Common Lisp projects, you might want to let Roswell set up your lisp environment for you.
# Set up Clang, libedit, and Roswell make LISP='ros -s cffi-grovel run --'
You can skip Roswell if you want. Just make sure that you set LISP
to a command that runs SBCL with Quicklisp and cffi-grovel loaded.
For example,
# Set up Clang, libedit, SBCL, and Quicklisp QUICKLISP_SETUP=~/quicklisp/setup.lisp # or wherever you installed quicklisp make LISP="sbcl --no-userinit --load \"$QUICKLISP_SETUP\" --eval '(ql:quickload :cffi-grovel)'"
I don’t know what you’re expecting to see here. Its a POSIX-like shell. You can do (almost) all your normal POSIX shell stuff in it.
shcl> echo foobar foobar shcl> FOO=$(echo echo foo; false) || echo assignment returned false assignment returned false shcl> $FOO foo shcl> { echo foobar ; echo baz ; echo blip ; } | tail -n 1 blip shcl> shcl-enable-lisp-syntax shcl> if [ ,(+ 1 2 3) = ,(* 2 3) ]; then > echo woah > fi woah shcl> shcl-repl shcl (lisp)> (format t "Hello world~%") Hello world NIL shcl (lisp)> (define-builtin set-env (&option print &required var value) > (loop :for str :across print :do (format t "~A~%" str)) > (setf (env var) value) > 0) SET-ENV shcl (lisp)> ^D shcl> set-env --print hi --print there VAR value | wc -l 2 shcl> echo $VAR value shcl> ^D
Okay, actually, that kind of went off the rails.