[BusyBox] hush progress
Matt Kraai
kraai at alumni.carnegiemellon.edu
Wed May 2 11:53:34 UTC 2001
On Wed, May 02, 2001 at 09:18:33AM -0700, Larry Doolittle wrote:
> Interesting test case progress. With the appended patch
> (which I sent to Matt about 10 minutes ago):
>
> setup: echo THIS IS A TEST >foo
> passes: cat $(echo FOO | tr 'A-Z' 'a-z')
> passes: cat foo | tr 'A-Z' 'a-z'
> fails: cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z'
The problem is that the $(...) and `...` operators do not strip
the trailing newline. As a result, it interprets the last command
as
cat foo
| tr 'A-Z' 'a-z'
This causes it to print the contents of foo unadulterated, and
then tolower on stdin from the tty. This is pretty clear in the
following example:
kraai at opensource:~/dev/busybox$ ./busybox sh
hush -- the humble shell v0.01 (testing)
/home/kraai/dev/busybox $ echo `echo -n FOO` true | tr 'A-Z' 'a-z'
foo true
/home/kraai/dev/busybox $ echo `echo FOO` true | tr 'A-Z' 'a-z'
FOO
This is also seriously broken for embedded newlines:
/home/kraai/dev/busybox $ echo `echo -e foo\\\necho bar`
foo
bar
I just committed a patch to fix this. It will only process the
newline as a command separator if the end_trigger is not '\0'.
This fixes the above case, and I believe some problems with $
substitutions as well.
Matt
More information about the busybox
mailing list