'This usually leads to screenfuls of error messages and users praying that in this megabyte of binary garbage no valid shell commands occur'
hit a nerve.
>If there is such nonblank text then for [most unices] this group consists of precisely one argument, as in the example above where argi consists of the single argument "-a -b".<p>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.
> Many Unix systems will consider a `\r' in a DOS-type line-ending (`\r\n') part of the interpreter arguments. (HP-UX, Solaris, UnixWare ignore trailing `\r'. AIX, BSD/OS, FreeBSD, Linux, OpenBSD, Tru64 do not.)<p>"/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.<p>Probably a common failure point, if people use small local scripts in their work-flow, and happen to tweak one in a Windows machine.
There is at last one more case: binfmt_misc on Linux, which gives you Windows-style run-based-on-file-extension.<p>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:<p><a href="http://serverfault.com/questions/82296/when-do-file-extensions-override-shebang-lines-on-linux" rel="nofollow">http://serverfault.com/questions/82296/when-do-file-extensio...</a>