bin/127370: [patch] sh(1): sh -c 'exit -1' fails with "Illegal number: -1", instead of exiting with a code of 255

Christoph Mallon christoph.mallon at gmx.de
Sun Sep 14 21:00:08 UTC 2008


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

From: Christoph Mallon <christoph.mallon at gmx.de>
To: bug-followup at FreeBSD.org, andy.lavr at 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


More information about the freebsd-bugs mailing list