[BusyBox] Shell bug, or my snafu?

Charlie Brady charlieb-busybox at e-smith.com
Thu Mar 25 16:25:13 UTC 2004


I'm using busybox 1.00-pre5, linked with uClibc-0.9.19 (mipsel target).

I'm tweaking IFS for "on-the-cheap" parsing of filenames. But IFS seems to 
be being munged inside variable values. If I'm making a dumb mistake, 
please point it out to me. Otherwise I think we have a bug.

Here is the shell source:

   IFS='-'
    ls $tmpRouteDir | while read net mask gw metric
    do
        FILE="$tmpRouteDir/$net-$mask-$gw-$metric"
        if [ ! -f "$FILE" ] ; then
            echo could not find file "$FILE"
            continue
        fi
[snip]
    done

And note when we run the script, '-' in $FILE suddenly becomes space (and
that's space not within a quoted string):

...
+ IFS=-
+ ls /tmp/existing.routes
+ read net mask gw metric
+ FILE=/tmp/existing.routes/192.168.1.0-255.255.255.0-0.0.0.0-0
+ [ ! -f /tmp/existing.routes/192.168.1.0 255.255.255.0 0.0.0.0 0 ]
[: 255.255.255.0: unknown operand
+ [ 0 = 1 ]
+ rm /tmp/existing.routes/192.168.1.0 255.255.255.0 0.0.0.0 0
rm: cannot remove `/tmp/existing.routes/192.168.1.0': No such file or 
directory
rm: cannot remove `255.255.255.0': No such file or directory
rm: cannot remove `0.0.0.0': No such file or directory
rm: cannot remove `0': No such file or directory
+ read net mask gw metric
...

--
Charlie




More information about the busybox mailing list