NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/37493: /bin/sh exits if shift fails, but shouldn't



The following reply was made to PR bin/37493; it has been noted by GNATS.

From: Alan Barrett <apb%cequrux.com@localhost>
To: gnats-bugs%NetBSD.org@localhost, netbsd-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/37493: /bin/sh exits if shift fails, but shouldn't
Date: Sun, 25 May 2008 09:49:53 +0000

 On Sun, 25 May 2008, David Holland wrote:
 >  > >How-To-Repeat:
 >  > $ sh -c 'set -ex; shift || echo failed.'
 >  > + shift
 >  > shift: can't shift that many
 
 > I'm thinking that shift should be changed to an ordinary builtin
 > instead of a special builtin. But I'm not sure what other implications
 > this might have. Would someone who understands the finer points of sh
 > like to comment?
 
 shift is required to be a special built-in utility
 <http://www.opengroup.org/onlinepubs/009695399/utilities/shift.html>.
 
 According to one part of SUSv3, syntax errors in
 special built-in utilities are permitted, but
 not required, to make the shell exit immediately
 
<http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_14>.
 
 According to another part of SUSv3, an "option or operand error"
 in a special built-in utility means that the shell must exit
 
<http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_08_01>.
 I think that trying to shift too many parameters would fall under this
 category.
 
 > Also... ksh exhibits the same behavior. So, apparently, does the
 > original Bourne shell. bash and zsh do not. Which makes it unclear if
 > it's really a bug or not, too...
 
 I say "not a bug".
 
 --apb (Alan Barrett)
 


Home | Main Index | Thread Index | Old Index