[BusyBox 0000947]: The order of variable evaluation by bash's implementation of /bin/sh differs from normal /bin/sh

bugs at busybox.net bugs at busybox.net
Fri Feb 15 15:02:35 UTC 2008


The following issue has been CLOSED 
====================================================================== 
http://busybox.net/bugs/view.php?id=947 
====================================================================== 
Reported By:                anthony
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   947
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     closed
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             07-14-2006 09:02 PDT
Last Modified:              02-15-2008 07:02 PST
====================================================================== 
Summary:                    The order of variable evaluation by bash's
implementation of /bin/sh differs from normal /bin/sh
Description: 
For the command
  X=usbdev X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D

On the normal /bin/sh, the result is:
  bus/usb/1/2

On busybox's /bin/sh, the result is:
  bus/usb//

To get the same result you need to modify the command to:
  X=usbdev; X=${X#usbdev}; B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D

This seems to be a difference in the way the two shells evaluate
variables, and means that some scripts when copied from a standard
environment to a busybox environment may fail unexpectedly. (I picked this
up when copying udev rules into an initramdisk that uses busybox).

This is true for all versions of busy box from 1.1.2 to the current
development version.
====================================================================== 

---------------------------------------------------------------------- 
 anthony - 07-28-06 04:30  
---------------------------------------------------------------------- 
For some reason the commands are incorrect, they should be:

X=usbdev1.2 X=${X#usbdev} B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D

followed by

X=usbdev1.2; X=${X#usbdev}; B=${X%%.*} D=${X#*.}; echo bus/usb/$B/$D 

---------------------------------------------------------------------- 
 vda - 02-15-08 07:02  
---------------------------------------------------------------------- 
Fixed in revision 21030. Thanks! 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-14-06 09:02  anthony        New Issue                                    
07-14-06 09:02  anthony        Status                   new => assigned     
07-14-06 09:02  anthony        Assigned To               => BusyBox         
07-28-06 04:30  anthony        Note Added: 0001549                          
02-15-08 07:02  vda            Status                   assigned => closed  
02-15-08 07:02  vda            Note Added: 0004884                          
======================================================================




More information about the busybox-cvs mailing list