summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-10-28 22:34:49 +0000
committerjilles <jilles@FreeBSD.org>2010-10-28 22:34:49 +0000
commit6f54496b1660e6b4fd963cbd53a65890e2eaa8d4 (patch)
tree2f18c22be103c9782bf005a232148a34a49dc0bd /tools
parent07e9b6a42f3f0bfbd8d8639ce46cf42a1c275a3a (diff)
downloadFreeBSD-src-6f54496b1660e6b4fd963cbd53a65890e2eaa8d4.zip
FreeBSD-src-6f54496b1660e6b4fd963cbd53a65890e2eaa8d4.tar.gz
sh: Only accept a '}' inside ${v+-=?...} if double-quote state matches.
If double-quote state does not match, treat the '}' literally. This ensures double-quote state remains the same before and after a ${v+-=?...} which helps with expand.c. It makes things like ${foo+"\${bar}"} which I have seen in the wild work as expected. Exp-run done by: pav (with some other sh(1) changes)
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/plus-minus5.031
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/plus-minus5.0 b/tools/regression/bin/sh/expansion/plus-minus5.0
new file mode 100644
index 0000000..0b25e53
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/plus-minus5.0
@@ -0,0 +1,31 @@
+# $FreeBSD$
+
+e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
+h='##'
+failures=''
+ok=''
+
+testcase() {
+ code="$1"
+ expected="$2"
+ oIFS="$IFS"
+ eval "$code"
+ IFS='|'
+ result="$#|$*"
+ IFS="$oIFS"
+ if [ "x$result" = "x$expected" ]; then
+ ok=x$ok
+ else
+ failures=x$failures
+ echo "For $code, expected $expected actual $result"
+ fi
+}
+
+testcase 'set -- ${e:-"{x}"}' '1|{x}'
+testcase 'set -- "${e:-"{x}"}"' '1|{x}'
+testcase 'set -- ${h+"{x}"}' '1|{x}'
+testcase 'set -- "${h+"{x}"}"' '1|{x}'
+testcase 'set -- ${h:-"{x}"}' '1|##'
+testcase 'set -- "${h:-"{x}"}"' '1|##'
+
+test "x$failures" = x
OpenPOWER on IntegriCloud