Bug 845 - ASH fails to handle semi-complex "test"
Summary: ASH fails to handle semi-complex "test"
Status: RESOLVED WORKSFORME
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-07 18:08 UTC by Myke Smith
Modified: 2010-02-01 02:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Myke Smith 2010-01-07 18:08:41 UTC
Encountered this problem in running Oprofile's control script (opcontrol) on BusyBox 1.11.2.

This shows up when you use the single character option, for instance  "-d" instead of the "--dump" option. The problem occurs when you do

if test -z "$2" -a "$1" = "--reset";  then

running with -xv option I see using the "-d" option

+ test -z  -a -d = --reset                        <<<<<<<<<< $2  evaluates to null, $1 evaluates to -d
sh: --reset: unknown operand          
+ load_module

running with -xv option I see using the "--dump" option

+ test -z  -a --dump = --reset                <<<<<<<<<< $2 evaluates  to null, $1 evaluates to --dump
+ load_module

I tried as an alternative

if [  \( -z "$2"\) -a \("$1" = "--reset" \) ]; then

but using either the -d or --dump option I got
+ [ ( -z ) -a (-d = --reset) ]
sh: closing paren expected      

The only workaround that works is:

 if test \( -z "$2"\) -a \("$1" = "--reset" \) ; then

+ test ( -z ) -a (-d = --reset )                 <<<<<<<<<< $2  evaluates to null, $1 evaluates to -d
+ load_module

+ test ( -z ) -a (--dump = --reset )      <<<<<<<<<< $2  evaluates to null, $1 evaluates to --dump
+ load_module
Comment 1 Denys Vlasenko 2010-01-08 12:14:33 UTC
This was fixed in later versions. 1.11.2 is old.
Comment 2 Myke Smith 2010-01-30 23:22:16 UTC
Unable to move up to a newer version of BusyBox so I am not able to personally check. I will leave the resolution as is.

Do you me to move this to CLOSED?
Comment 3 Denys Vlasenko 2010-02-01 02:58:35 UTC
CLOSED or RESOLVED, I don't see the difference