sh: Make double-quotes quote a '}' inside ${v#...} and ${v%...}.

Exp-run done by:	pav (with some other sh(1) changes)
PR:			bin/57554
This commit is contained in:
Jilles Tjoelker 2010-10-28 21:51:14 +00:00
parent ac203a768d
commit 9cec947f3f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214490
2 changed files with 30 additions and 1 deletions

View File

@ -1234,7 +1234,8 @@ readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs)
case CENDVAR: /* '}' */
if (level > 0 &&
(state[level].category == TSTATE_VAR_OLD ||
state[level].category == TSTATE_VAR_NEW)) {
(state[level].category == TSTATE_VAR_NEW &&
state[level].syntax == BASESYNTAX))) {
if (state[level].category == TSTATE_VAR_OLD)
state[level - 1].syntax = state[level].syntax;
else

View File

@ -0,0 +1,28 @@
# $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 -- "${b%'\'}\''}"' '1|{{(#)}'
testcase 'set -- ${b%"}"}' '1|{{(#)}'
testcase 'set -- "${b%"}"}"' '1|{{(#)}'
test "x$failures" = x