Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-28 Thread Clint Adams
Package: mksh
Version: 38.3-1

% mksh /tmp/horsies ; echo $?   
/tmp/horsies: /tmp/horsies: No such file or directory
1

According to SUSv3, the exit code should be 127:

  127
A specified command_file could not be found by a non-interactive shell.



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



Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-28 Thread Thorsten Glaser
Dixi quod:

>(as stdin replacement)

More on this:

t...@frozenfish:~ $ mksh
t...@frozenfish:~ $ true 

Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-28 Thread Thorsten Glaser
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? Is there, by chance, an eMail
address (mailing list, maybe) where people can ask such questions on
SUSv3 and shell behaviour? I'm adding you because you helped out so
well last time when we had the "$@" vs set -u issue.

10x,
//mirabilos
-- 
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
-- Tonnerre Lombard in #nosec



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



Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-29 Thread Geoff Clare
Thorsten Glaser  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



Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-29 Thread Thorsten Glaser
Geoff Clare dixit:

>Clint is right.  Look at the synopsis for sh:

Okay, the HTML versions I had were not easy to search.
Then I’ll fix that in mksh, and Clint should file it
with dash too.

>The Austin Group mailing list is open to anyone to join.  See
>
>www.opengroup.org/austin/lists.html

Thanks!

>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

Very useful, greatly appreciated.

bye,
//mirabilos
-- 
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
-- Tonnerre Lombard in #nosec



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



Bug#548744: mksh: exit status of non-interactive file-not-found

2009-09-29 Thread Thorsten Glaser
Geoff Clare dixit:

>So the 127 exit is required for "sh /tmp/horsies" if /tmp/horsies could
>not be found.

Heh. The source code even *tried* to DTRT, setting exstat to 127,
but the errorf() function doing the actual abortion set it to 1…
fixed.

//mirabilos
-- 
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
-- Tonnerre Lombard in #nosec



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