On May 21, 2023, at 20:57, Robert Nichols <rnicholsNOSPAM(a)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=871bb4...
Which uses _PATH_BSHELL in paths.h
(
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/...)
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