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 <>
Subject: Re: bin/37493: /bin/sh exits if shift fails, but shouldn't
Date: Sun, 25 May 2008 22:18:08 +0000

 On Sun, 25 May 2008, David Holland wrote:
 >  > 
 > <>.
 >  > I think that trying to shift too many parameters would fall under this
 >  > category.
 > Well, no. It says "Utility syntax error (option or operand error)",
 > and it doesn't define this any more specifically anywhere in the whole
 > chapter. At least that I can find. I don't see that an out-of-range
 > value qualifies as a syntax error.
 I had thought that the value passed to shift was an "operand", and
 that it was an "error" for this value to be larger than the number of
 positional parameters available to the shell; hence an "operand error".
 However, Greg's and your argument ...
 > Meanwhile, the definition of shift explicitly says that its exit
 > status is nonzero if the count is out of range, which would be
 > meaningless if the shell were required to exit in this context.  By
 > the magical properties of reasoning about standards, it therefore must
 > not be required to exit in this context.
 > (I see Greg A. Woods has deployed approximately the same reasoning...)
 ... has convinced me that I was wrong.
 >  > I say "not a bug".
 > Nah, it's clearly allowed by POSIX, but I don't think we can claim
 > it's required, and it's certainly not *desirable* behavior.
 I agree with all that.  (I previously thought that it was required but
 undesirable; I now think that it's allowed, not required, and still
 --apb (Alan Barrett)

Home | Main Index | Thread Index | Old Index