Mark Whitley | 04052f9 | 2001-05-24 17:15:33 +0000 | [diff] [blame] | 1 | # try running this with bash, ksh, ash, and hush. |
Mark Whitley | 4f6aea8 | 2001-05-24 23:05:13 +0000 | [diff] [blame] | 2 | |
| 3 | # simple quoting rules. |
| 4 | echo a b |
| 5 | echo "a b" |
| 6 | echo a "" b |
| 7 | echo a '' b |
| 8 | echo hello? |
| 9 | echo "hello?" |
| 10 | echo t* hello |
| 11 | echo t\* hello |
| 12 | |
| 13 | # quick and painless exit for lash |
| 14 | if false; then true; exit; fi |
| 15 | |
| 16 | # fairly simple command substitution |
Mark Whitley | 04052f9 | 2001-05-24 17:15:33 +0000 | [diff] [blame] | 17 | echo `echo -e foo\\\necho bar` |
| 18 | |
| 19 | echo THIS IS A TEST >foo |
| 20 | cat $(echo FOO | tr 'A-Z' 'a-z') |
| 21 | cat foo | tr 'A-Z' 'a-z' |
| 22 | cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z' |
| 23 | |
| 24 | cat foo | if true; then tr 'A-Z' 'a-z'; else echo bar1; fi |
| 25 | cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi |
| 26 | if true; then tr 'A-Z' 'a-z'; else echo bar3; fi <foo |
| 27 | if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo |
| 28 | if true || false; then echo foo; else echo bar5; fi |
| 29 | if true && false; then echo bar6; else echo foo; fi |
| 30 | |
Mark Whitley | 4f6aea8 | 2001-05-24 23:05:13 +0000 | [diff] [blame] | 31 | # fairly simple example of hush expanding variables too early |
| 32 | unset TMP |
| 33 | rm -f fish |
| 34 | TMP=fish && >$TMP |
| 35 | ls fish |
| 36 | |
| 37 | # ash, lash, and hush do not create fish; bash and ksh do. |
Mark Whitley | 04052f9 | 2001-05-24 17:15:33 +0000 | [diff] [blame] | 38 | # Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test. |
| 39 | unset TMP |
| 40 | rm -f fish |
| 41 | TMP=fish >$TMP |
| 42 | ls fish |
| 43 | |
| 44 | # The following example shows that hush's parser is |
| 45 | # not _really_ Bourne compatible |
| 46 | echo "echo Hello World" >"a=b" |
| 47 | unset a |
| 48 | chmod a+x "a=b" |
| 49 | PATH=$PATH:. |
| 50 | "a=b" |
| 51 | echo $a |
| 52 | |
| 53 | # assuming the shell wasn't too buggy, clean up the mess |
| 54 | rm -f a=b fish foo |