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. 

See: https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/execvpe.c;h=871bb4c49891b5997ce70980a7cbce40271a3964;hb=HEAD

Which uses _PATH_BSHELL in paths.h (https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/paths.h;h=1342ab3a96ab12065311b718e57e7235e07587f8;hb=HEAD)

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. 

--
Jonathan Billings