Subject: bin/37493: /bin/sh exits if shift fails, but shouldn't
To: None <,>
From: None <>
List: netbsd-bugs
Date: 12/06/2007 21:55:01
>Number:         37493
>Category:       bin
>Synopsis:       /bin/sh exits if shift fails, but shouldn't
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 06 21:55:01 +0000 2007
>Originator:     Roland Illig
>Release:        NetBSD 4.99.30
When "shift" is used in "set -e" mode, the shell exits if the "shift"
occurs in a conditional statement. This is unexpected and not covered by
the documentation.

$ sh -c 'set -ex; shift || echo failed.'
+ shift
shift: can't shift that many

$ bash -c 'set -ex; shift || echo failed.'
+ shift
+ echo failed.