Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] return status 126 for execution failures other than 'not found'

On Fri, May 8, 2020 at 1:37 PM Martijn Dekker <martijn@xxxxxxxx> wrote:
> Currently, the execute() function in Src/exec.c only returns status 126
> if the error code is EACCES (permission denied) or ENOEXEC (exec format
> error). In all other cases, 127 is returned.
> That logic is not right, because 127 is the specific case: it is only to
> be used if the command was not found. Any failure to execute after the
> command is found should yield status 126.

Aside from the "zsh is not POSIX unless invoked as sh" standpoint ...

> The attached patch changes that logic to return status 127 if there is
> no error number (which happens if a PATH search does not find a command)
> or if the error number is ENOENT (no such file or directory). In all
> other cases it now returns 126.

... shouldn't EPERM also be in that list?  A file that's not
executable or otherwise not reachable seems to fall into the "not
found" category.

Messages sorted by: Reverse Date, Date, Thread, Author