blob: e2a75873e3594f517b74a374c321cd7391443c3d [file] [log] [blame]
Mark Whitley04052f92001-05-24 17:15:33 +00001# try running this with bash, ksh, ash, and hush.
Mark Whitley4f6aea82001-05-24 23:05:13 +00002
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
Mark Whitley04052f92001-05-24 17:15:33 +000017echo `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
Eric Andersen04407e52001-06-07 16:42:05 +000031# 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
Matt Kraai12422ff2001-06-05 17:48:47 +000060# 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
Mark Whitley4f6aea82001-05-24 23:05:13 +000066# 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.
Mark Whitley04052f92001-05-24 17:15:33 +000073# 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