untangle them:
Rewrite u_signal_names() into get_signum() and get_signame(), plus trim the
signal list to that required by posix (they can specify the numbers for
the rest if they really need them). (This is preparatory cleanup for adding
a timeout applet like Roberto Foglietta wants.)
Export the itoa (added due to Denis Vlasenko, although it's not quite his
preferred implementation) from xfuncs.c so it's actually used, and remove
several other redundant implementations of itoa and utoa() in the tree.
This patch makes msh handle variable expansion within backticks more
correctly.
Current behaviour (wrong):
--------------------------
BusyBox v1.00-rc3 (2004.08.26-11:51+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
$ A='`echo hello`'
$ echo $A
`echo hello`
$ echo `echo $A`
hello
$
New behaviour (correct):
------------------------
BusyBox v1.00-rc3 (2004.08.26-11:51+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
$ A='`echo hello`'
$ echo $A
`echo hello`
$ echo `echo $A`
`echo hello`
$
The current behaviour (wrong according to standards) was actually my
fault. msh handles backticks by executing a subshell (which makes it
work on MMU-less systems). Executing a subshell makes it hard to only
expand variables once in the parent. Therefore I export all variables
that will be expanded within the backticks and let the subshell handle
the expansion instead.
The bug was found while searching for security leaks in CGI-scripts.
Current behaviour of msh makes it easy to expand backticks by mistake
in $QUERY_STRING. I recommend appling the patch before release of bb
1.00.
/Jonas
A question was posted a month ago by Mark Alamo to see if others had
problems with sourcing subscripts within msh. We asked his firm to fix the
msh.c bug he described because we didn't have enough time to do it
ourselves.
When msh.c is executing a compound statement and there is a . command to
source another script file, msh.c will not execute the subscript until it's
completed executing the rest of the compound statement.
His example was this:
Echo "Start" ; . ./subA; echo "mid" ; . ./subB ; echo "end"
subA and subB execute AFTER end is printed in reverse order. The same is
true if the sourced files are inside an if else fi, case esac, or any
compound statement.
Attached is a patch to msh.c. It fixes the problem. Cd to the root of your
busybox tree and execute "patch -p1 < msh.c.patch"
Unfortunately, I won't have more time to work on this so I hope that there
aren't any problems!
Michael Leibow
Senior Software Engineer
Belkin Corporation