[BusyBox 0001380]: /usr/bin/[ gives "[: ]: unknown operand" message

bugs at busybox.net bugs at busybox.net
Tue Jun 5 15:44:18 UTC 2007


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1380 
====================================================================== 
Reported By:                dmaizer
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1380
Category:                   Other
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             06-05-2007 08:44 PDT
Last Modified:              06-05-2007 08:44 PDT
====================================================================== 
Summary:                    /usr/bin/[ gives "[: ]: unknown operand" message
Description: 
We are working in an Apache (httpd 2.2.3) suexec CGI scripts environment
and our CGI scripts need to provide full paths to all applets/programs
used, so we have something like the following in the CGI script:

if /usr/bin/[ $# -lt 1 ]; then
   /bin/echo "sitediag: too few arguments"
   /bin/echo "Try sitediag --help for more information"
   exit 1
fi

However - this gives the error:
[: ]: unknown operand

Meaning that the "]" closing bracket is being recognized as an unknown
operand. But of course this bracket is needed to close the test...

If we remove the /usr/bin prefix from [ - then it works and gives the
expected echo messages above.

I tried looking at busybox code (being no expert of that code) and found
the following in coreutils/test.c:

	if (*t_wp != NULL && *++t_wp != NULL) {
		bb_error_msg("%s: unknown operand", *t_wp);
		return 2;
	}

My guess is that somehow using the pathname causes that condition above to
be true, but I haven't been able to find out why yet (I started looking
from ash.c and "lower" to see why this happens, but haven't been able to
find anything meaningful so far - hopefully someone who knows the code
better can provide a clue or a fix.
====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
06-05-07 08:44  dmaizer        New Issue                                    
06-05-07 08:44  dmaizer        Status                   new => assigned     
06-05-07 08:44  dmaizer        Assigned To               => BusyBox         
======================================================================




More information about the busybox-cvs mailing list