Eric Blake wrote: > Conversely, POSIX requires that execution by 'sh' is the expected > behavior when #! is missing, and that use of #! renders a script > non-portable: > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_01
This paragraph specifies what happens when you run sh some-file Here, maint.mk invokes xargs, which invokes 'useless-if-before-free'. xargs is not a shell. Therefore the portions of POSIX that matter here are 1) The description of "Executable File" in section 3.154 of https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html "The internal format of an executable file is unspecified" 2) The description of the exec() system call: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html "Historically, there have been two ways that implementations can exec shell scripts. One common historical implementation is that the execl(), execv(), execle(), and execve() functions return an [ENOEXEC] error for any file not recognizable as executable, including a shell script. When the execlp() and execvp() functions encounter such a file, they assume the file to be a shell script and invoke a known command interpreter to interpret such files. This is now required by POSIX.1-2017. ..." 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. Bruno