[PATCH] [INPUT] Catch attempts to run a directory as a script

2010-10-06 Thread Jonathan Nieder
open() succeeds, though read() fails later, when a pathname passed as argv[0] on the command line points to a directory, which somehow results in dash thinking everything is okay: $ sh dir/ $ echo $? 0 But POSIX makes it clear enough that in sh command_file, command_file is supposed to be a

Re: [PATCH] [INPUT] Catch attempts to run a directory as a script

2010-10-06 Thread Jonathan Nieder
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?

Re: [PATCH] [INPUT] Catch attempts to run a directory as a script

2010-10-06 Thread Eric Blake
On 10/06/2010 04:55 AM, 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

Re: [PATCH] [INPUT] Catch attempts to run a directory as a script

2010-10-06 Thread Herbert Xu
On Wed, Oct 06, 2010 at 06:18:05AM -0600, Eric Blake wrote: Right now, dash gets this wrong: dash -c 'exec .'; echo $? exec: 1: /: Permission denied 2 And since you already have the code in dash to detect failure to 'exec' a directory, you should be able to reuse that code when