maknel
maknel

Reputation: 309

Common Lisp Shebang Script Gives "Command Not Found"

I'm tyring to run a Common Lisp shebang script (test.lisp) on MacOS using SBCL. The script is below:

#!/usr/local/bin/Cellar/sbcl/1.5.6/bin/sbcl --script
(write-line "test")

I ran chmod +x on the script to make it executable, and when I run it I get:

./test.lisp: line 2: write-line: command not found

I made sure my SBCL path was correct. I originally tried /usr/local/bin/sbcl, but that gave me the same error.

How can I fix this?

Upvotes: 3

Views: 623

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

Do not use such specific paths in shebang script lines, especially if they contain version numbers, as the location/version of those binaries are likely to change and break the script.

Instead use /usr/bin/env to find the executable, and in your case that's:

#!/usr/bin/env sbcl --script

Upvotes: 3

Related Questions