Shell scripts need a shell-bang line in it in order to be run via execve
or anything that uses it, such as run-program
. So you should use this as your file's content:
#!/bin/sh
exec /Applications/Safari.app/Contents/MacOS/Safari
سؤال
I've seen this question but it doesn't seem to apply here.
Using SBCL, this works fine:
(run-program "/bin/ls" () :output *standard-output*)
So does this:
(run-program "/Applications/Safari.app/Contents/MacOS/Safari" ())
It launches a Safari window.
I can create a bash script in my bin
directory that just has this in it:
/Applications/Safari.app/Contents/MacOS/Safari
When I run this bash script from the Terminal, Safari opens.
But I cannot run this script from inside SBCL:
(run-program "/Users/myhome/bin/safariscript" ())
REPL reports:
Couldn't execute "/Users/myhome/bin/safariscript": Exec format error
[Condition of type SIMPLE-ERROR]
The script certainly works fine on its own. I've searched ad nauseum for the meaning of this error without any help that would apply to a lisp environment, so I wonder if there is a broader issue at play here?
المحلول
Shell scripts need a shell-bang line in it in order to be run via execve
or anything that uses it, such as run-program
. So you should use this as your file's content:
#!/bin/sh
exec /Applications/Safari.app/Contents/MacOS/Safari