1# try running this with bash, ksh, ash, and hush.
2
3# simple quoting rules.
4echo a  b
5echo "a  b"
6echo a "" b
7echo a '' b
8echo hello?
9echo "hello?"
10echo t* hello
11echo t\* hello
12
13# quick and painless exit for lash
14if false; then true; exit; fi
15
16# fairly simple command substitution
17echo `echo -e foo\\\necho bar`
18
19echo THIS IS A TEST >foo
20cat $(echo FOO | tr 'A-Z' 'a-z')
21cat foo | tr 'A-Z' 'a-z'
22cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z'
23
24cat foo | if true;  then tr 'A-Z' 'a-z'; else echo bar1; fi
25cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi
26if true;  then tr 'A-Z' 'a-z'; else echo bar3; fi <foo
27if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo
28if true || false; then echo foo; else echo bar5; fi
29if true && false; then echo bar6; else echo foo; fi
30
31# basic distinction between local and env variables
32unset FOO
33FOO=bar env | grep FOO
34echo "but not here: $FOO"
35FOO=bar
36env | grep FOO
37echo "yes, here: $FOO"
38FOO=
39echo a $FOO b
40echo "a $FOO b"
41
42# not quite so basic variables.  Credit to Matt Kraai.
43unset FOO
44FOO=bar
45export FOO
46env | grep FOO
47unset FOO
48export FOO=bar
49FOO=baz
50env | grep FOO
51
52# interaction between environment variables and if/then and subshells
53FOO=default
54if true; then FOO=new; fi
55echo $FOO
56FOO=default
57(FOO=bogus)
58echo $FOO
59
60# make sure we can duplicate file descriptors properly
61echo replacement >foo 2>&1
62cat foo
63cat doesnt_exist >foo 2>&1
64tr 'a-z' 'A-Z' <foo
65
66# fairly simple example of hush expanding variables too early
67unset TMP
68rm -f fish
69TMP=fish && >$TMP
70ls fish
71
72# ash, lash, and hush do not create fish; bash and ksh do.
73# Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test.
74unset TMP
75rm -f fish
76TMP=fish >$TMP
77ls fish
78
79# The following example shows that hush's parser is
80# not _really_ Bourne compatible
81echo "echo Hello World" >"a=b"
82unset a
83chmod a+x "a=b"
84PATH=$PATH:.
85"a=b"
86echo $a
87
88# assuming the shell wasn't too buggy, clean up the mess
89rm -f a=b fish foo
90