4 ms·
While I agree about the use of /usr/bin/env, you should be aware that some systems will perform only one word split on the shebang line. That means that if you
by etanol 14y ago
While I agree about the use of /usr/bin/env, you should be aware that some systems will perform only one word split on the shebang line. That means that if you use env, you can't pass any options to the $executable.
You can try it if you want, save this into an executable file (test.awk):
#!/usr/bin/env awk -f
{ print $2 }
Then run:
echo "Hello world again" | ./test.awk
I get the following:
/usr/bin/env: awk -f: No such file or directory
- masklinn 14y ago> I get the following: Damn. I get "world" (OSX, zsh, BSD env) So I supposed you can't pass options to `env` either (e.g. `-i`, or ENVVAR overrides?)
- etanol 14y agoThis is a kernel issue, it has nothing to do with userspace tools. For example, the Linux code responsible for parsing shebangs is here: http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=blob;f=fs/binfmt_script.c;h=d3b8c1f6315554df64d3491b52d83d2a73f4a359;hb=HEAD#l17 http://git.kernel.org/?p=linux/kernel/git/stable/linux-stabl...
- masklinn 14y agoInteresting, thanks for the info. I wouldn't have thought it so low in the architecture.