Thorsten Glaser <t...@mirbsd.de> wrote, on 28 Sep 2009:
>
> Clint Adams dixit:
> 
> >% mksh /tmp/horsies ; echo $?                                   
> >/tmp/horsies: /tmp/horsies: No such file or directory
> >1
> 
> t...@herc:~ $ mksh /tmp/horsies; print $?
> /tmp/horsies: /tmp/horsies: No such file or directory
> 1
> t...@herc:~ $ mksh -c /tmp/horsies; print $?
> mksh: /tmp/horsies: not found
> 127
> 
> >According to SUSv3, the exit code should be 127:
> >
> >  127
> >    A specified command_file could not be found by a non-interactive shell.
> 
> I tend to disagree. While GNU bash, AT&T ksh93 and zsh do the same
> thing for both, neither does dash, nor can I find (quickly) something
> in SUSv3 which says anything about the return code when the input file
> (as stdin replacement) cannot be opened. The case you bring forward is
> *not* a command_file.
> 
> Geoff, can you shed some light on this?

Clint is right.  Look at the synopsis for sh:

   sh [-abCefhimnuvx] [-o option]... [+abCefhimnuvx] [+o option]...
          [command_file [argument...]]

   sh -c [-abCefhimnuvx] [-o option]... [+abCefhimnuvx] [+o option]...
          command_string [command_name [argument...]]

In the command

  sh /tmp/horsies

the /tmp/horsies argument is a command_file operand.  In the command

  sh -c /tmp/horsies

the /tmp/horsies argument is a command_string operand.

So the 127 exit is required for "sh /tmp/horsies" if /tmp/horsies could
not be found.  (127 is also required for "sh -c /tmp/horsies", but for
a different reason.)

> Is there, by chance, an eMail
> address (mailing list, maybe) where people can ask such questions on
> SUSv3 and shell behaviour?

The Austin Group mailing list is open to anyone to join.  See

www.opengroup.org/austin/lists.html

David Korn and Chet Ramey are both subscribers, and sometimes
contribute to shell-related discussions.

By the way, the base specifications (XBD, XSH, XCU, XRAT) of SUSv3
were superseded by the SUSv4 equivalents about a year ago.  You can
access the HTML version of the new specifications via

www.opengroup.org/bookstore/catalog/c082.htm

If you join the Austin Group mailing list you can also get access
to the PDF version.

Regards,
Geoff.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to