1# Tests for command substitution. 2 3%prep 4 mkdir cmdsubst.tmp 5 touch cmdsubst.tmp/file{1,2}.txt 6 7%test 8 foo="two words" 9 print -l `echo $foo bar` 100:Basic `...` substitution 11>two 12>words 13>bar 14 15 foo="two words" 16 print -l $(echo $foo bar) 170:Basic $(...) substitution 18>two 19>words 20>bar 21 22 foo='intricate buffoonery' 23 print -l "`echo $foo and licentiousness`" 240:Quoted `...` substitution 25>intricate buffoonery and licentiousness 26 27 foo="more words" 28 print -l "$(echo $foo here)" 290:Quoted $(...) substitution 30>more words here 31 32# we used never to get this one right, but I think it is now... 33 print -r "`print -r \\\\\\\\`" 340:Stripping of backslasshes in quoted `...` 35>\\ 36 37 print -r "$(print -r \\\\\\\\)" 380:Stripping of backslashes in quoted $(...) 39>\\\\ 40 41 fnify() { print \"$*\"; } 42 print `fnify \`fnify understatement\`` 430:Nested `...` 44>""understatement"" 45 46 print $(fnify $(fnify overboard)) 470:Nested $(...) 48>""overboard"" 49 50 fructify() { print \'$*\'; } 51 print "`fructify \`fructify indolence\``" 520:Nested quoted `...` 53>''indolence'' 54 55 print "$(fructify $(fructify obtuseness))" 560:Nested quoted $(...) 57>''obtuseness'' 58 59 gesticulate() { print \!$*\!; } 60 print $((gesticulate wildly); gesticulate calmly) 610:$(( ... ) ... ) is not arithmetic 62>!wildly! !calmly! 63 64 commencify() { print +$*+; } 65 print "$((commencify output); commencify input)" 660:quoted $(( ... ) .. ) is not arithmetic 67>+output+ 68>+input+ 69 70 ( 71 cd cmdsubst.tmp 72 print first: ${$(print \*)} 73 print second: ${~$(print \*)} 74 print third: ${$(print *)} 75 print fourth: "${~$(print \*)}" 76 print fifth: ${~"$(print \*)"} 77 ) 780:mixing $(...) with parameter substitution and globbing 79>first: * 80>second: file1.txt file2.txt 81>third: file1.txt file2.txt 82>fourth: * 83>fifth: file1.txt file2.txt 84 85 $(exit 0) $(exit 3) || print $? 860:empty command uses exit value of last substitution 87>3 88 89 X=$(exit 2) $(exit 0) || print $? 900:variable assignments processed after other substitutions 91>2 92 93 false 94 `` 950:Empty command substitution resets status 96 97 false 98 echo `echo $?` 990:Non-empty command substitution inherits status 100>1 101 102 echo $(( ##\" )) 103 echo $(echo \") 104 echo $((echo \"); echo OK) 1050:Handling of backslash double quote in parenthesised substitutions 106>34 107>" 108>" OK 109