summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-03-12 23:23:46 +0000
committerjilles <jilles@FreeBSD.org>2010-03-12 23:23:46 +0000
commit13b8d0250999c3444c159ddf9ef56d78c4edbd02 (patch)
treed39c07df1708fd198b01247452177c02855c5acc /tools
parent5db64758fcb81922e732307039ff65d0d7c6f36c (diff)
downloadFreeBSD-src-13b8d0250999c3444c159ddf9ef56d78c4edbd02.zip
FreeBSD-src-13b8d0250999c3444c159ddf9ef56d78c4edbd02.tar.gz
sh: Add tests for " and $ inside `.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/cmdsubst2.043
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/cmdsubst2.0 b/tools/regression/bin/sh/expansion/cmdsubst2.0
new file mode 100644
index 0000000..b86776e
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/cmdsubst2.0
@@ -0,0 +1,43 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+ if ! eval "[ $* ]"; then
+ echo "Failed: $*"
+ : $((failures += 1))
+ fi
+}
+
+check '`echo /et[c]/` = "/etc/"'
+check '`printf /var/empty%s /et[c]/` = "/var/empty/etc/"'
+check '"`echo /et[c]/`" = "/etc/"'
+check '`echo "/et[c]/"` = "/etc/"'
+check '`printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"'
+check '`printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""'
+check '"`echo \"/et[c]/\"`" = "/et[c]/"'
+check '"`echo "/et[c]/"`" = "/et[c]/"'
+check '`echo $$` = $$'
+check '"`echo $$`" = $$'
+check '`echo \$\$` = $$'
+check '"`echo \$\$`" = $$'
+
+# Command substitutions consisting of a single builtin may be treated
+# differently.
+check '`:; echo /et[c]/` = "/etc/"'
+check '`:; printf /var/empty%s /et[c]/` = "/var/empty/etc/"'
+check '"`:; echo /et[c]/`" = "/etc/"'
+check '`:; echo "/et[c]/"` = "/etc/"'
+check '`:; printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"'
+check '`:; printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""'
+check '"`:; echo \"/et[c]/\"`" = "/et[c]/"'
+check '"`:; echo "/et[c]/"`" = "/et[c]/"'
+check '`:; echo $$` = $$'
+check '"`:; echo $$`" = $$'
+check '`:; echo \$\$` = $$'
+check '"`:; echo \$\$`" = $$'
+
+check '`set -f; echo /et[c]/` = "/etc/"'
+check '"`set -f; echo /et[c]/`" = "/et[c]/"'
+
+exit $((failures > 0))
OpenPOWER on IntegriCloud