[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alpine: useless-if-before-free: Exec format error

From: Bruno Haible
Subject: Re: Alpine: useless-if-before-free: Exec format error
Date: Sat, 15 Jun 2019 01:17:38 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-145-generic; KDE/5.18.0; x86_64; ; )

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
   "The internal format of an executable file is unspecified"

2) The description of the exec() system call:
   "Historically, there have been two ways that implementations can exec shell
    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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]