about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-11 21:59:29 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-11 21:59:29 +0000
commit970345731f4b9d6afe9a4965a287552a57514b05 (patch)
tree20cb4cbe08a51c519562eb5cc3d14a2b52774e3b /Test
parent66ae2822dd269332a06641d8fc0da0c0e60734eb (diff)
downloadzsh-970345731f4b9d6afe9a4965a287552a57514b05.tar.gz
zsh-970345731f4b9d6afe9a4965a287552a57514b05.tar.xz
zsh-970345731f4b9d6afe9a4965a287552a57514b05.zip
Merge of 23131: new tests for command substitution.
Diffstat (limited to 'Test')
-rw-r--r--Test/D08cmdsubst.ztst83
1 files changed, 83 insertions, 0 deletions
diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst
new file mode 100644
index 000000000..6cbcbf929
--- /dev/null
+++ b/Test/D08cmdsubst.ztst
@@ -0,0 +1,83 @@
+# Tests for command substitution.
+
+%prep
+  mkdir cmdsubst.tmp
+  touch cmdsubst.tmp/file{1,2}.txt
+
+%test
+  foo="two words"
+  print -l `echo $foo bar`
+0:Basic `...` substitution
+>two
+>words
+>bar
+
+  foo="two words"
+  print -l $(echo $foo bar)
+0:Basic $(...) substitution
+>two
+>words
+>bar
+
+  foo='intricate buffoonery'
+  print -l "`echo $foo and licentiousness`"
+0:Quoted `...` substitution
+>intricate buffoonery and licentiousness
+
+  foo="more words"
+  print -l "$(echo $foo here)"
+0:Quoted $(...) substitution
+>more words here
+
+# we used never to get this one right, but I think it is now...
+  print -r "`print -r \\\\\\\\`"
+0:Stripping of backslasshes in quoted `...`
+>\\
+
+  print -r "$(print -r \\\\\\\\)"
+0:Stripping of backslashes in quoted $(...)
+>\\\\
+
+  fnify() { print \"$*\"; }
+  print `fnify \`fnify understatement\``
+0:Nested `...`
+>""understatement""
+
+  print $(fnify $(fnify overboard))
+0:Nested $(...)
+>""overboard""
+
+  fructify() { print \'$*\'; }
+  print "`fructify \`fructify indolence\``"
+0:Nested quoted `...`
+>''indolence''
+
+  print "$(fructify $(fructify obtuseness))"
+0:Nested quoted $(...)
+>''obtuseness''
+
+  gesticulate() { print \!$*\!; }
+  print $((gesticulate wildly); gesticulate calmly)
+0:$(( ... ) ... ) is not arithmetic
+>!wildly! !calmly!
+
+  commencify() { print +$*+; }
+  print "$((commencify output); commencify input)"
+0:quoted $(( ... ) .. ) is not arithmetic
+>+output+
+>+input+
+
+  (
+  cd cmdsubst.tmp
+  print first: ${$(print \*)}
+  print second: ${~$(print \*)}
+  print third: ${$(print *)}
+  print fourth: "${~$(print \*)}"
+  print fifth: ${~"$(print \*)"}
+  )
+0:mixing $(...) with parameter substitution and globbing
+>first: *
+>second: file1.txt file2.txt
+>third: file1.txt file2.txt
+>fourth: *
+>fifth: file1.txt file2.txt