Skip to content

Instantly share code, notes, and snippets.

@jasom
Last active December 29, 2015 17:47
Show Gist options
  • Save jasom/467cbb40667f96f75ae4 to your computer and use it in GitHub Desktop.
Save jasom/467cbb40667f96f75ae4 to your computer and use it in GitHub Desktop.
Alternative way of launching lisp scripts on *nix
'eval' #|
exec sbcl --script "$0" "$@"
# |#
nil ;; this completes the quote from before the comment
(format t "Hello, ~A!~%" (or (second sb-ext:*posix-argv*) "world"))
@jasom
Copy link
Author

jasom commented Dec 29, 2015

This is completely portable so long as it contains only characters from the "C" locale, as posix mandates loading an executable file as a shell script if ENOEXEC is returned.

Advantages over shebang include:

  • Can customize arguments to sbcl (shebang only allows exactly 1 argument portably)
  • Is a valid lisp-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment