Date: Sun, 14 Sep 2008 21:00:08 GMT From: Christoph Mallon <christoph.mallon@gmx.de> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/127370: [patch] sh(1): sh -c 'exit -1' fails with "Illegal number: -1", instead of exiting with a code of 255 Message-ID: <200809142100.m8EL08qV011713@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/127370; it has been noted by GNATS. From: Christoph Mallon <christoph.mallon@gmx.de> To: bug-followup@FreeBSD.org, andy.lavr@reactor-xg.kiev.ua Cc: Subject: Re: bin/127370: [patch] sh(1): sh -c 'exit -1' fails with "Illegal number: -1", instead of exiting with a code of 255 Date: Sun, 14 Sep 2008 22:32:14 +0200 > Bourne shell (/bin/sh), as it stands, doesn't parse numbers properly, even though bash does: > > [gcooper at optimus /devel/ncvs/src/bin/sh]$ sh -c 'exit -1' > exit: Illegal number: -1 > [gcooper at optimus /devel/ncvs/src/bin/sh]$ sh -c 'exit +1' > exit: Illegal number: +1 > > These are valid numbers though, which are merely red herrings; The standard (SUSv2, chapter Shell Command Language, http://www.opengroup.org/onlinepubs/7990989775/xcu/chap2.html#tag_001_014_007) is pretty clear in this respect: "The exit utility causes the shell to exit with the exit status specified by the unsigned decimal integer n. If n is specified, but its value is not between 0 and 255 inclusively, the exit status is undefined." It clearly states that the exit status must be an *unsigned* decimal integer. The changes, which you propose, are clearly bashisms and should not be part of sh. Regards Christoph
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809142100.m8EL08qV011713>