>    Since xargs happens to use execvp(), the executable gets executed by "a
>    known command interpreter". This command interpreter might be sh, python,
>    emacs, or whatever.
> 
> So, the *omission* of #! renders a script non-portable, when that script is
> invoked like an executable.

Anyway, there seems to be an agreement that execvp() needs to execute scripts
through a command interpreter, unlike execv().

  * The glibc source code does so, see glibc/posix/execvpe.c.
    Also the description of this commit:
    
https://sourceware.org/git/?p=glibc.git;a=commit;h=283d98512272a12cb84e7798c23edbdf1adb287d

  * The musl author agrees as well:
    https://www.openwall.com/lists/musl/2018/03/09/1
    https://www.openwall.com/lists/musl/2018/03/09/2
    https://www.openwall.com/lists/musl/2018/03/11/1

So, the ENOEXEC error is a bug in musl. But POSIX does not specify that the
command interpreter for scripts without shebang is /bin/sh; therefore IMHO
it would be good not to make this assumption.

Bruno


Reply via email to