summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrij Czarkoff <czarkoff@cvs.openbsd.org>2016-03-04 09:37:24 +0000
committerDmitrij Czarkoff <czarkoff@cvs.openbsd.org>2016-03-04 09:37:24 +0000
commit8ba29e461549abf45561c21f5869c5cd106ac7fa (patch)
treea8a243b0b1d594fcb2fb382875081bbb379de98d
parent0d943e2187d60efcf2c0cca6074b08bd663702f0 (diff)
don't parse (...|...) patterns in variable substitution inside double quotes
fixes posix compatibility issue OK millert@, nicm@, otto@
-rw-r--r--bin/ksh/lex.c11
-rw-r--r--regress/bin/ksh/unclass1.t8
2 files changed, 18 insertions, 1 deletions
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index 568a960c06c..73c54b3af37 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.67 2015/12/30 09:07:00 tedu Exp $ */
+/* $OpenBSD: lex.c,v 1.68 2016/03/04 09:37:23 czarkoff Exp $ */
/*
* lexical analysis and source input
@@ -582,6 +582,15 @@ yylex(int cf)
break;
case SBRACEQ:
+ /*{*/
+ if (c == '}') {
+ POP_STATE();
+ *wp++ = CSUBST;
+ *wp++ = /*{*/ '}';
+ } else
+ goto Sbase2;
+ break;
+
case SBRACE:
/*{*/
if (c == '}') {
diff --git a/regress/bin/ksh/unclass1.t b/regress/bin/ksh/unclass1.t
index 7322f5b4f0a..45115499601 100644
--- a/regress/bin/ksh/unclass1.t
+++ b/regress/bin/ksh/unclass1.t
@@ -73,6 +73,14 @@ expected-stdout:
a*
---
+name: qouted-brace-expansion-2
+stdin:
+ foo='bar'
+ echo "${foo+(a)}*"
+expected-stdout:
+ (a)*
+---
+
name: xxx-prefix-strip-1
stdin:
foo='a cdef'