[BusyBox] sh.testcases
Larry Doolittle
ldoolitt at recycle.lbl.gov
Fri May 18 13:26:36 UTC 2001
# sh.testcases
# 18-May-2001 Larry Doolittle <LRDoolittle at lbl.gov>
#
# try running this with bash, ksh, ash, and hush.
# lash is too lame to get very far.
# hush revision 1.29 does pretty well when these are pasted into
# an interactive session (well, except for a few "sh: tcsetpgrp:
# Invalid argument" messages), but "../busybox sh sh.testcases"
# fails miserably.
# 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'
cat $(echo FOO | tr 'A-Z' 'a-z') | 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
# This is a really oddball case: ash, ksh, and hush do not create fish;
# bash does. Tough. Credit to Tapani Tarvainen <tt at mit.jyu.fi>
# hush revision 1.29 segfaults. Aaaurgh!
# ash dies attempting the redirection.
unset TMP
rm -f fish
TMP=fish >$TMP
ls fish
echo "proceeded past Tapani test"
# The following example shows that hush's parser is
# not _really_ Bourne compatible
echo "echo Hello World" >"a=b"
unset a
chmod a+x "a=b"
PATH=$PATH:.
"a=b"
echo $a
# assuming the shell wasn't too buggy, clean up the mess
rm -f a=b fish foo
More information about the busybox
mailing list