From: Jonathan Nieder <jrnieder@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Gerrit Pape <pape@smarden.org>,
dash@vger.kernel.org, "Krzysztof A. Sobiecki" <sobkas@gmail.com>,
Jari Aalto <jari.aalto@cante.net>
Subject: Re: [PATCH] [INPUT] Catch attempts to run a directory as a script
Date: Wed, 6 Oct 2010 05:55:31 -0500 [thread overview]
Message-ID: <20101006105531.GB475@burratino> (raw)
In-Reply-To: <20101006102930.GA6573@gondor.apana.org.au>
Herbert Xu wrote:
> On Wed, Oct 06, 2010 at 05:08:04AM -0500, Jonathan Nieder wrote:
>> But POSIX makes it clear enough that in "sh command_file",
>> command_file is supposed to be a file, not a directory. So
>> diagnose this with an error message and exit with status 2.
[...]
> Is this required by POSIX? If not this is simply making dash
> bigger for no good reason.
Not clear. I suppose POSIX usually doesn't require anything when the
caller screws up.
Jari Aalto quoted the DESCRIPTION section[1] (and some similar
passages):
> The sh utility is a command language interpreter that shall
> execute commands read from a command line string, the standard
> >> input, or a specified file.
I don't find that alone very convincing.
Under OPERANDS[2]: if the path contains a slash, all the standard says
is "the implementation attempts to read that file". If the path does
not contain a slash and the file is not in the working directory, the
implementation _may_ perform a search as described in "Command Search
and Execution".
During that search, after execve() fails, "if the executable file is
not a text file, the shell _may_ bypass this command execution. In
this case, it shall write an error message, and shall return an exit
status of 126." (emphasis mine).
So this behavior is allowed as an optional subset of an optional
behavior. That may have guided the bash implementors:
$ bash directory
directory: directory: is a directory
$ echo $?
126
It's probably not required.
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=10;bug=548687
[2] http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_05
next prev parent reply other threads:[~2010-10-06 10:58 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-05 16:06 debian patches to exit with code 127 for nonexistent/directory scripts Jilles Tjoelker
2010-06-08 10:19 ` Herbert Xu
2010-06-08 10:36 ` Cristian Ionescu-Idbohrn
2010-06-11 8:39 ` Herbert Xu
2010-06-14 9:54 ` [PATCH] [INPUT] exit 127 if command_file is given but doesn't exist Gerrit Pape
2010-06-28 6:53 ` Herbert Xu
2010-10-06 10:04 ` [PATCH] [OPTIONS] Use exit status 127 when the script to run does not exist Jonathan Nieder
2010-10-06 10:08 ` [PATCH] [INPUT] Catch attempts to run a directory as a script Jonathan Nieder
2010-10-06 10:29 ` Herbert Xu
2010-10-06 10:55 ` Jonathan Nieder [this message]
2010-10-06 12:18 ` Eric Blake
2010-10-06 12:31 ` Herbert Xu
2010-10-07 1:02 ` [PATCH 0/3] Fix exit status for 'exec nonexistent' and 'exec .' Jonathan Nieder
2010-10-07 1:03 ` [PATCH 1/3] [EXCEPTIONS] Stop documenting EXSHELLPROC Jonathan Nieder
2010-10-07 3:01 ` Herbert Xu
2010-10-07 3:04 ` Jonathan Nieder
2010-10-07 3:29 ` Herbert Xu
2010-10-07 3:39 ` [PATCH v2] " Jonathan Nieder
2010-11-28 12:47 ` Herbert Xu
2010-10-07 1:04 ` [PATCH 2/3] Revert "Eliminated global exerrno." Jonathan Nieder
2010-10-07 2:56 ` Herbert Xu
2010-10-07 3:35 ` Jonathan Nieder
2010-10-07 4:14 ` Herbert Xu
2010-10-07 4:37 ` Herbert Xu
2010-10-07 21:34 ` Jonathan Nieder
2010-11-28 12:45 ` Herbert Xu
2010-10-07 1:08 ` [PATCH 3/3] [EXCEPTIONS] Eliminate global exerrno Jonathan Nieder
2010-10-07 3:00 ` Herbert Xu
2010-11-28 12:06 ` [PATCH] [OPTIONS] Use exit status 127 when the script to run does not exist Herbert Xu
2010-11-28 12:24 ` Herbert Xu
2010-11-28 12:33 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101006105531.GB475@burratino \
--to=jrnieder@gmail.com \
--cc=dash@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=jari.aalto@cante.net \
--cc=pape@smarden.org \
--cc=sobkas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox