diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 21:32:24 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-10-13 21:32:24 +0000 |
commit | ec3c5af51bfcb51f976b184af54d6b0c12b077f3 (patch) | |
tree | 62bbeddd3e75559a71fa45465439dc59493d27b1 /bin/ksh/tests | |
parent | 647a0f92a2544a00265b0a8eaff14f417a2dbe0f (diff) |
Update to version 5.2.11.
Diffstat (limited to 'bin/ksh/tests')
-rw-r--r-- | bin/ksh/tests/alias.t | 91 | ||||
-rw-r--r-- | bin/ksh/tests/bksl-nl.t | 339 | ||||
-rw-r--r-- | bin/ksh/tests/heredoc.t | 110 | ||||
-rw-r--r-- | bin/ksh/tests/version.t | 2 |
4 files changed, 522 insertions, 20 deletions
diff --git a/bin/ksh/tests/alias.t b/bin/ksh/tests/alias.t new file mode 100644 index 00000000000..0db6a2594cd --- /dev/null +++ b/bin/ksh/tests/alias.t @@ -0,0 +1,91 @@ +name: alias-1 +description: + Check that recursion is detected/avoided in aliases. +stdin: + alias fooBar=fooBar + fooBar + exit 0 +expected-stderr-pattern: + /fooBar.*not found.*/ +--- + +name: alias-2 +description: + Check that recursion is detected/avoided in aliases. +stdin: + alias fooBar=barFoo + alias barFoo=fooBar + fooBar + barFoo + exit 0 +expected-stderr-pattern: + /fooBar.*not found.*\n.*barFoo.*not found/ +--- + +name: alias-3 +description: + Check that recursion is detected/avoided in aliases. +stdin: + alias Echo='echo ' + alias fooBar=barFoo + alias barFoo=fooBar + Echo fooBar + unalias barFoo + Echo fooBar +expected-stdout: + fooBar + barFoo +--- + +name: alias-4 +description: + Check that alias expansion isn't done on keywords (in keyword + postitions). +stdin: + alias Echo='echo ' + alias while=While + while false; do echo hi ; done + Echo while +expected-stdout: + While +--- + +name: alias-5 +description: + Check that alias expansion done after alias with trailing space. +stdin: + alias Echo='echo ' + alias foo='bar stuff ' + alias bar='Bar1 Bar2 ' + alias stuff='Stuff' + alias blah='Blah' + Echo foo blah +expected-stdout: + Bar1 Bar2 Stuff Blah +--- + +name: alias-6 +description: + Check that alias expansion done after alias with trailing space. +stdin: + alias Echo='echo ' + alias foo='bar bar' + alias bar='Bar ' + alias blah=Blah + Echo foo blah +expected-stdout: + Bar Bar Blah +--- + +name: alias-7 +description: + Check that alias expansion done after alias with trailing space + after a keyword. +stdin: + alias X='case ' + alias Y=Z + X Y in 'Y') echo is y ;; Z) echo is z ; esac +expected-stdout: + is z +--- + diff --git a/bin/ksh/tests/bksl-nl.t b/bin/ksh/tests/bksl-nl.t new file mode 100644 index 00000000000..3fb92ff53b5 --- /dev/null +++ b/bin/ksh/tests/bksl-nl.t @@ -0,0 +1,339 @@ +# +# These tests deal with how \newline is handled in various situations. The +# first group of tests are places where it shouldn't be collapsed, the next +# group of tests are places where it should be collapsed. +# +name: bksl-nl-ign-1 +description: + Check that \newline is not collasped after # +stdin: + echo hi #there \ + echo folks +expected-stdout: + hi + folks +--- + +name: bksl-nl-ign-2 +description: + Check that \newline is not collasped inside single quotes +stdin: + echo 'hi \ + there' + echo folks +expected-stdout: + hi \ + there + folks +--- + +name: bksl-nl-ign-3 +description: + Check that \newline is not collasped inside single quotes +stdin: + cat << \EOF + hi \ + there + EOF +expected-stdout: + hi \ + there +--- + +name: blsk-nl-ign-4 +description: + Check interaction of aliases, single quotes and here-documents + with backslash-newline + (don't know what posix has to say about this) +stdin: + a=2 + alias x='echo hi + cat << "EOF" + foo\ + bar + some' + x + more\ + stuff$a + EOF +expected-stdout: + hi + foo\ + bar + some + more\ + stuff$a +--- + +name: blsk-nl-ign-5 +description: + Check what happens with backslash at end of input + (the old bourne shell trashes them; so do we) +stdin: ! + echo `echo foo\\`bar + echo hi\ +expected-stdout: + foobar + hi +--- + + +# +# Places \newline should be collapsed +# +name: bksl-nl-1 +description: + Check that \newline is collasped before, in the middle of, and + after words +stdin: + \ + echo hi\ + There, \ + folks +expected-stdout: + hiThere, folks +--- + +name: bksl-nl-2 +description: + Check that \newline is collasped in $ sequences + (ksh93 fails this) +stdin: + a=12 + ab=19 + echo $\ + a + echo $a\ + b + echo $\ + {a} + echo ${a\ + b} + echo ${ab\ + } +expected-stdout: + 12 + 19 + 12 + 19 + 19 +--- + +name: bksl-nl-3 +description: + Check that \newline is collasped in $(..) and `...` sequences + (ksh93 fails this) +stdin: + echo $\ + (echo foobar1) + echo $(\ + echo foobar2) + echo $(echo foo\ + bar3) + echo $(echo foobar4\ + ) + echo ` + echo stuff1` + echo `echo st\ + uff2` +expected-stdout: + foobar1 + foobar2 + foobar3 + foobar4 + stuff1 + stuff2 +--- + +name: bksl-nl-4 +description: + Check that \newline is collasped in $((..)) sequences + (ksh93 fails this) +stdin: + echo $\ + ((1+2)) + echo $(\ + (1+2+3)) + echo $((\ + 1+2+3+4)) + echo $((1+\ + 2+3+4+5)) + echo $((1+2+3+4+5+6)\ + ) +expected-stdout: + 3 + 6 + 10 + 15 + 21 +--- + +name: bksl-nl-5 +description: + Check that \newline is collasped in double quoted strings +stdin: + echo "\ + hi" + echo "foo\ + bar" + echo "folks\ + " +expected-stdout: + hi + foobar + folks +--- + +name: bksl-nl-6 +description: + Check that \newline is collasped in here document delimiters + (ksh93 fails second part of this) +stdin: + a=12 + cat << EO\ + F + a=$a + foo\ + bar + EOF + cat << E_O_F + foo + E_O_\ + F + echo done +expected-stdout: + a=12 + foobar + foo + done +--- + +name: bksl-nl-7 +description: + Check that \newline is collasped in double-quoted here-document + delimiter. +stdin: + a=12 + cat << "EO\ + F" + a=$a + foo\ + bar + EOF + echo done +expected-stdout: + a=$a + foo\ + bar + done +--- + +name: bksl-nl-8 +description: + Check that \newline is collasped in various 2+ character tokens + delimiter. + (ksh93 fails this) +stdin: + echo hi &\ + & echo there + echo foo |\ + | echo bar + cat <\ + < EOF + stuff + EOF + cat <\ + <\ + - EOF + more stuff + EOF + cat <<\ + EOF + abcdef + EOF + echo hi >\ + > /dev/null + echo $? + i=1 + case $i in + (\ + x|\ + 1\ + ) echo hi;\ + ; + (*) echo oops + esac +expected-stdout: + hi + there + foo + stuff + more stuff + abcdef + 0 + hi +--- + +name: blsk-nl-9 +description: + Check that \ at the end of an alias is collapsed when followed + by a newline + (don't know what posix has to say about this) +stdin: + alias x='echo hi\' + x + echo there +expected-stdout: + hiecho there +--- + +name: blsk-nl-10 +description: + Check that \newline in a keyword is collapsed +stdin: + i\ + f true; then\ + echo pass; el\ + se echo fail; fi +expected-stdout: + pass +--- + +# +# Places \newline should be collapsed (ksh extensions) +# + +name: blsk-nl-ksh-1 +description: + Check that \newline is collapsed in extended globbing + (ksh93 fails this) +stdin: + xxx=foo + case $xxx in + (f*\ + (\ + o\ + )\ + ) echo ok ;; + *) echo bad + esac +expected-stdout: + ok +--- + +name: blsk-nl-ksh-2 +description: + Check that \newline is collapsed in ((...)) expressions + (ksh93 fails this) +stdin: + i=1 + (\ + (\ + i=i+2\ + )\ + ) + echo $i +expected-stdout: + 3 +--- + diff --git a/bin/ksh/tests/heredoc.t b/bin/ksh/tests/heredoc.t index 27c28302258..21feb925cea 100644 --- a/bin/ksh/tests/heredoc.t +++ b/bin/ksh/tests/heredoc.t @@ -20,33 +20,18 @@ stdin: hi\ there$a stuff - EOF -expected-stdout: - hi\ - there$a - stuff ---- - -name: heredoc-3 -description: - Check quoted here-documents don't have \newline processing done - on them. -stdin: - cat << 'EOF' - hi\ - there EO\ F EOF - true expected-stdout: hi\ - there + there$a + stuff EO\ F --- -name: heredoc-4 +name: heredoc-3 description: Check that newline isn't needed after heredoc-delimiter marker. stdin: ! @@ -59,7 +44,7 @@ expected-stdout: there --- -name: heredoc-5 +name: heredoc-4 description: Check that an error occurs if the heredoc-delimiter is missing. stdin: ! @@ -70,3 +55,90 @@ expected-exit: e > 0 expected-stderr-pattern: /.*/ --- +name: heredoc-5 +description: + Check that backslash quotes a $, ` and \ and kills a \newline +stdin: + a=BAD + b=ok + cat << EOF + h\${a}i + h\\${b}i + th\`echo not-run\`ere + th\\`echo is-run`ere + fol\\ks + more\\ + last \ + line + EOF +expected-stdout: + h${a}i + h\oki + th`echo not-run`ere + th\is-runere + fol\ks + more\ + last line +--- + +name: heredoc-6 +description: + Check that \newline in initial here-delim word doesn't imply + a quoted here-doc. +stdin: + a=i + cat << EO\ + F + h$a + there + EOF +expected-stdout: + hi + there +--- + +name: heredoc-7 +description: + Check that double quoted $ expressions in here delimiters are + not expanded and match the delimiter. + POSIX says only quote removal is applied to the delimiter. +stdin: + a=b + cat << "E$a" + hi + h$a + hb + E$a + echo done +expected-stdout: + hi + h$a + hb + done +--- + +name: heredoc-8 +description: + Check that double quoted escaped $ expressions in here + delimiters are not expanded and match the delimiter. + POSIX says only quote removal is applied to the delimiter + (\ counts as a quote). +stdin: + a=b + cat << "E\$a" + hi + h$a + h\$a + hb + h\b + E$a + echo done +expected-stdout: + hi + h$a + h\$a + hb + h\b + done +--- + diff --git a/bin/ksh/tests/version.t b/bin/ksh/tests/version.t index e1b8127fcbc..51abf75f296 100644 --- a/bin/ksh/tests/version.t +++ b/bin/ksh/tests/version.t @@ -4,5 +4,5 @@ description: stdin: echo $KSH_VERSION expected-stdout: - @(#)PD KSH v5.2.9 96/09/30 + @(#)PD KSH v5.2.11 96/10/08 --- |