summaryrefslogtreecommitdiff
path: root/tests/sh.testcases
blob: 9b5c8da597e2131809d15fc9b7d8ee9086f46af1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# try running this with bash, ksh, ash, and hush.

# simple quoting rules.
echo a  b
echo "a  b"
echo a "" b
echo a '' b
echo hello?
echo "hello?"
echo t* hello
echo t\* hello

# quick and painless exit for lash
if false; then true; exit; fi

# 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'

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

# fairly simple example of hush expanding variables too early
unset TMP
rm -f fish
TMP=fish && >$TMP
ls fish

# ash, lash, and hush do not create fish; bash and ksh do.
# Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test.
unset TMP
rm -f fish
TMP=fish >$TMP
ls fish

# 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