On May 21, 2023, at 20:57, Robert Nichols <rnicholsNOSPAM@comcast.net> wrote:
Not quite. What happens is that your shell's exec() call fails with "ENOEXEC (Exec format error)". When your shell (not the kernel) sees that for a file that does have execute permission, it forks a copy of itself to try to interpret the file as a script in your shell's own language. The result depends on whether the script is compatible with your current shell.
I tried to give a simple response in my answer, but it’s actually glibc (on Linux) that handles the exec* functions (called by the shell, of course), and it passes it on to /bin/sh and *not* the users shell.
The fact that different terminals behave differently make me wonder if it’s something to do with terminal I/O or something else weird.
Anyway, use a shebang.