[BusyBox 0006294]: expr overloads exitcode of 1 to mean several different things (mismatch with coreutils)

bugs at busybox.net bugs at busybox.net
Tue Nov 11 22:37:46 UTC 2008


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=6294 
====================================================================== 
Reported By:                pgbovine
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   6294
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             11-11-2008 13:55 PST
Last Modified:              11-11-2008 14:37 PST
====================================================================== 
Summary:                    expr overloads exitcode of 1 to mean several
different things (mismatch with coreutils)
Description: 
>From 'info expr':

   Exit status:

     0 if the expression is neither null nor 0,
     1 if the expression is null or 0,
     2 if the expression is invalid,
     3 if an internal error occurred (e.g., arithmetic overflow).

Busybox overloads exitcode 1 both to signify a successful exit with a
'false' value and to signify a syntax error. In contrast, coreutils uses a
special exit code 2 to signify a syntax error.

Coreutils:
$ expr '1' '<' '0'
0
$ echo $?
1

(this expression is valid and FALSE, so coreutils properly returns an
exitcode of 1)

$ expr '<' '0'
expr: syntax error
$ echo $?
2

(this expression is INVALID, so coreutils properly returns an exitcode of
2)

Busybox:
$ ./busybox expr '1' '<' '0'
0
$ echo $?
1

(so far, so good)

$ ./busybox expr '<' '0'
expr: syntax error
$ echo $?
1

(uh oh, should return exitcode of 2 here rather than 1.)
====================================================================== 

---------------------------------------------------------------------- 
 vda - 11-11-08 14:37  
---------------------------------------------------------------------- 
Please try attached 9.patch 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
11-11-08 13:55  pgbovine       New Issue                                    
11-11-08 13:55  pgbovine       Status                   new => assigned     
11-11-08 13:55  pgbovine       Assigned To               => BusyBox         
11-11-08 14:37  vda            File Added: 9.patch                          
11-11-08 14:37  vda            Note Added: 0015474                          
======================================================================




More information about the busybox-cvs mailing list