On Thu, Oct 05, 2023 at 07:04:26AM +0200, Phi Debian wrote: > Since we are on the error path (not the perf path) may be the shell could > go the extra miles and try some more diag, has it does for shebang, on > ENOENT, the shell could try to open the a.out, if OK try some other > euristics, [...]
Just for the record, trying to open the program for reading is only possible for scripts. It's not too uncommon for a compiled program to have +x permission for the user, but *not* +r permission. Such a program can be executed, but not opened for reading. This permission combo is primarily used for setuid programs on some systems, where it's believed that letting the user read the program might give them insight into finding security exploits in it. Such systems are typically not open source, although it wouldn't surprise me one bit if there are also some BSD/Linux systems with programs like this. Another reason some people might use this permission combo is to "protect their intellectual property", by allowing end users to run the program, but not to make a copy of it. This obviously only works if the owner of the system (and anyone else with root access) is trusted not to make copies. So, it's an incredibly niche situation, but it might still be in use somewhere.