On 20/11/2018 21:56, Dan Kegel wrote:
I was surprised to discover that: touch foo chmod +x foo ./foo echo $? outputs 0 on the linux, mac, and bsd systems I've tried; on Linux I tried both bash and dash. Is this expected? I did a quick scan of the standard but didn't see anything related.
It's not specified directly, but if the shell attempts to execute a file that execl() rejects with ENOEXEC, and the file is a text file that does not start with #!, the standard requires it to be interpreted as a shell script. An empty file is a valid text file, so must be treated as an empty shell script.
Thanks, Dan