# - the Unix truth
homepages.cwi.nl
homepages.cwi.nl
Interesting. This seems pretty unintuitive, I would expect the "-a", "-b" behaviour. (I recognise that this would be more complicated to implement and make it impossible to pass an argument with spaces.) It seems like it could easily cause problems especially if you use `env` to handle paths. But I don't think I've ever run afoul of this.
#!/usr/local/bin/sudo -u someuser /bin/shTry the following files:
#!/usr/bin/sed -f
s/a/b/g
s/c/d/g
#!/usr/bin/sed -e 's/a/b/g' -f
s/c/d/gRemoving the quotes gives "-e expression #1, char 10: unknown option to `s'", because "s/a/b/g -f" is not a valid sed command.
And to illustrate my point about env, sed for me is in /bin. But "#!/usr/bin/env sed -f" doesn't work, because it looks for a program named "sed -f".
"/bin/sh^M: bad interpreter: No such file or directory" is what Linux gives nowadays after a shell script is edited in Windows' Notepad. I have an idea it used to be more cryptic.
Probably a common failure point, if people use small local scripts in their work-flow, and happen to tweak one in a Windows machine.
I had a run-in with it on a shared host with some PHP cron jobs (don't ask). The hosting company changed the handler for *.php and everything broke until I renamed the files. The whole story:
http://serverfault.com/questions/82296/when-do-file-extensio...
It is rumored that some systems only recognize an
executable script when it starts with the four bytes
`#! /', probably because the GNU autoconf manual says so,
but it seems impossible to find confirmation for this rumor.However, I've never read of any systems that have a problem with whitespace, so I suppose it's just as well to include it.