I get the error
/usr/bin/env: zsh -: No such file or directory
...when I run an executable
zsh script that starts with the following shebang line:
#!/usr/bin/env zsh -
Also, FWIW, replacing
/usr/bin/env to print a similar complaint about
I have only seen this error under ubuntu, and only in the context of the shebang hack. Under darwin the same script runs fine. And under ubuntu, running
% /usr/bin/env zsh -
from the command line succeeds. (Actually, "under ubuntu" should be understood as short-hand for "under ubuntu 12.04 LTS and
env (GNU coreutils) 8.13".)
My question is: how can I modify the shebang above to avoid this error?
Of course, I know that removing the trailing
- will eliminate the error, but this is not an acceptable solution. The rest of this post explains why.
The shebang line that is causing the error comes about as an attempt to comply with two entirely independent guidelines:
To make scripts portable, use
#!/usr/bin/env <cmd ...>rather than
-as the sole argument to
zshin the shebang line of zsh scripts thwarts certain types of attacks.
So, I can restate my question more precisely as follows: Is it possible to satisfy both of these guidelines without triggering the error shown above under ubuntu?