* PATCH: tests for command substitution.
@ 2007-01-23 21:22 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2007-01-23 21:22 UTC (permalink / raw)
To: Zsh hackers list
I noticed today we don't have tests specifically aimed at command
substitution.
Index: Test/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/.distfiles,v
retrieving revision 1.17
diff -u -r1.17 .distfiles
--- Test/.distfiles 18 Jul 2006 09:25:51 -0000 1.17
+++ Test/.distfiles 23 Jan 2007 21:21:17 -0000
@@ -7,7 +7,7 @@
A03quoting.ztst C04funcdef.ztst Makefile.in ztst.zsh
A04redirect.ztst D01prompt.ztst V02zregexparse.ztst
A05execution.ztst D02glob.ztst Y01completion.ztst
-D06subscript.ztst D07multibyte.ztst
+D06subscript.ztst D07multibyte.ztst D08cmdsubst.ztst
V01zmodload.ztst E01options.ztst
B02typeset.ztst B03print.ztst A06assign.ztst B04read.ztst
V03mathfunc.ztst
Index: Test/D08cmdsubst.ztst
===================================================================
RCS file: Test/D08cmdsubst.ztst
diff -N Test/D08cmdsubst.ztst
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Test/D08cmdsubst.ztst 23 Jan 2007 21:21:17 -0000
@@ -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
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-01-23 21:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-23 21:22 PATCH: tests for command substitution Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).