[BusyBox] hush variables patch

Larry Doolittle ldoolitt at recycle.lbl.gov
Tue May 22 13:48:13 UTC 2001


Hush is getting closer, given the limitations I discussed
in http://busybox.net/lists/busybox/2001-May/003621.html

The attached test file runs pretty well, there are still a
couple of local-variable issues it exposes, I suggest letting
Vladimir try fixing it first.

I haven't fixed the
$ pwd `echo 1`
problem yet.  I'll try that tonight, if nobody beats me to it.

     - Larry
-------------- next part --------------
# sh.testcases
# 22-May-2001  Larry Doolittle  <LRDoolittle at lbl.gov>
#
# try running this with bash, ksh, ash, and hush, and
# "diff" the results with each other.
# lash is too lame to get very far.
# hush revision 1.34 does pretty well, just a couple
# of problems left in local variable handling.

# simple quoting rules.
# lash revision 1.126 doesn't even pass the second hello? test.
echo a  b
echo "a  b"
echo a "" b
echo a '' b
echo hello?
echo "hello?"
echo t* hello
echo t\* hello

# fairly simple command substitution
echo `echo -e foo\\\necho bar`

echo THIS IS A TEST >foo
cat $(echo FOO | tr 'A-Z' 'a-z')
cat foo | tr 'A-Z' 'a-z'

# how conditionals interact with pipes, redirects, and lists
cat foo | if true;  then tr 'A-Z' 'a-z'; else echo bar1; fi
cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi
if true;  then tr 'A-Z' 'a-z'; else echo bar3; fi <foo
if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo
if true || false; then echo foo; else echo bar5; fi
if true && false; then echo bar6; else echo foo; fi

# basic distinction between local and env variables
unset FOO
FOO=bar env | grep FOO
echo "but not here: $FOO"
FOO=bar
env | grep FOO
echo "yes, here: $FOO"
FOO=
echo a $FOO b
echo "a $FOO b"

# not quite so basic variables.  Credit to Matt Kraai.
unset FOO
FOO=bar
export FOO
env | grep FOO

unset FOO
export FOO=bar
FOO=baz
env | grep FOO

# assuming the shell wasn't too buggy, clean up the mess
rm -f foo


More information about the busybox mailing list