For example, if I do
[OP@localhost executable]$ cat garbage
lalala
trololol
[OP@localhost executable]$ chmod +x garbage
[OP@localhost executable]$ ./garbage
./garbage: line 1: lalala: command not found
./garbage: line 2: trololol: command not found
Bash seems to be trying to interpret this "executable" as a script. However, there are two instances where this clearly does not happen: when the file begins with a #!, and ELF files. Are there any more? Is there a comprehensive documentation of this somewhere?
bashdoes that, but any program which is trying to run an executable file viaexecvp(2)orexeclp(2)(eg. tryxargs <garbage ./garbage). That's required by the POSIX standard. – Apr 11 '19 at 02:22sh, but bash tries to run it itself irrespective of whatshis. (compare a script withecho $BASH_VERSION $_, ran withbash -c ./foo.sh,dash -c ./foo.shandecho foo | xargs ./foo.sh– muru Apr 11 '19 at 02:33