From c17d5be2f1c0dc4ea71630b02f0f43e64ffb605c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 17 Feb 2020 21:18:14 -0600 Subject: More sh tests. --- tests/sh.test | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/sh.test') diff --git a/tests/sh.test b/tests/sh.test index d43ed89f..2bd83e4a 100755 --- a/tests/sh.test +++ b/tests/sh.test @@ -91,6 +91,15 @@ testing "leading variable assignments" \ testing "IFS whitespace before/after" \ 'IFS=" x"; A=" x " B=" x" C="x " D=x E=" "; for i in $A $B $C $D L$A L$B L$C L$D $A= $B= $C= $D= L$A= L$B= L$C= L$D=; do echo -n {$i}; done' \ "{}{}{}{}{L}{L}{L}{L}{}{=}{}{=}{}{=}{}{=}{L}{=}{L}{=}{L}{=}{L}{=}" "" "" +testing "quotes and whitespace" \ + 'A=" abc def "; for i in ""$A""; do echo =$i=; done' \ + "==\n=abc=\n=def=\n==\n" "" "" +testing "quotes and whitespace2" \ + 'A=" abc def "; for i in """"$A""; do echo =$i=; done' \ + "==\n=abc=\n=def=\n==\n" "" "" +testing "quotes and whitespace3" \ + 'A=" abc def "; for i in ""x""$A""; do echo =$i=; done' \ + "=x=\n=abc=\n=def=\n==\n" "" "" testing "IFS" 'IFS=x; A=abx; echo -n "$A"' "abx" "" "" testing "IFS2" 'IFS=x; A=abx; echo -n $A' "ab" "" "" @@ -101,13 +110,19 @@ testing '$*' 'cc(){ for i in $*;do echo =$i=;done;};cc "" "" "" "" ""' \ "" "" "" testing '$*2' 'cc(){ for i in "$*";do echo =$i=;done;};cc ""' \ "==\n" "" "" -# Flame. Flames. Flames, on the side of my face... -testing '$*3' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" ""' \ - "= =\n" "" "" +testing '$*3... Flame. Flames. Flames, on the side of my face...' \ + 'cc(){ for i in "$*";do echo =$i=;done;};cc "" ""' "= =\n" "" "" +testing 'why... oh.' \ + 'cc() { echo ="$*"=; for i in =$*=; do echo -$i-; done;}; cc "" ""; echo and; cc ""' \ + '= =\n-=-\n-=-\nand\n==\n-==-\n' "" "" +testing 'really?' 'cc() { for i in $*; do echo -$i-; done;}; cc "" "" ""' \ + "" "" "" +testing 'Sigh.' 'cc() { echo =$1$2=;}; cc "" ""' "==\n" "" "" testing '$*4' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "" "" "" ""' \ "= =\n" "" "" testing '$*5' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "abc" ""' \ "= abc =\n" "" "" + # creating empty arguments without quotes testing '$* + IFS' \ 'IFS=x; cc(){ for i in $*; do echo =$i=;done;};cc xabcxx' \ -- cgit v1.2.3