diff --git a/src/cmd/ksh93/sh/lex.c b/src/cmd/ksh93/sh/lex.c index da21d9d56..b9e7ef480 100644 --- a/src/cmd/ksh93/sh/lex.c +++ b/src/cmd/ksh93/sh/lex.c @@ -998,31 +998,13 @@ int sh_lex(Lex_t* lp) mode = ST_NESTED; continue; case S_MOD1: - if(oldmode(lp)==ST_QUOTE || oldmode(lp)==ST_NONE) - { - /* allow ' inside "${...}" */ - if(c==':' && fcgetc(n)>0) - { - n = state[n]; - fcseek(-LEN); - } - if(n==S_MOD1) - { - mode = ST_QUOTE; - continue; - } - } - /* FALL THRU */ + mode = ST_QUOTE; + continue; case S_MOD2: #if SHOPT_KIA if(lp->kiafile) refvar(lp,1); #endif /* SHOPT_KIA */ - if(c == ':' || c == '-' || c == '+' || c == '=') - { - mode = ST_QUOTE; - continue; - } if(c!=':' && fcgetc(n)>0) { if(n!=c) diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c index 67c454925..5605a21bc 100644 --- a/src/cmd/ksh93/sh/macro.c +++ b/src/cmd/ksh93/sh/macro.c @@ -1628,8 +1628,7 @@ retry1: } else { - int state = (!newops && mp->quote || c=='-' || c=='+' || c=='=') ? ST_QUOTE : ST_NESTED; - sh_lexskip(lp, RBRACE, 0, state); + sh_lexskip(lp, RBRACE, 0, sh_lexstates[ST_BRACE][c]==S_MOD1 ? ST_QUOTE : ST_NESTED); stkseek(stkp,offset); } argp=stkptr(stkp,offset); diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index 4fa7a1df1..d378358bb 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -1044,7 +1044,7 @@ wait [[ $$ == ${.sh.pid} ]] || err_exit "\${.sh.pid} and \$$ differ in the parent shell (expected $$, got ${.sh.pid})" # ====== -# Parentheses after the '-', '+', and '=' expansion operators were causing syntax errors. +# Parentheses after the '-', '+', '=', and '?' expansion operators were causing syntax errors. # Check both the unset variable case and the set variable case for each set of symbols. unset -v foo @@ -1058,7 +1058,7 @@ do for word in '(word)' 'w(or)d' '(wor)d' 'w(ord)' 'w(ord' 'wor)d' done foo=some_value -for op in - :- = := +for op in - :- = := \? :\? do for word in '(word)' 'w(or)d' '(wor)d' 'w(ord)' 'w(ord' 'wor)d' do exp=$(set +x; eval "echo \${foo${op}${word}}" 2>&1) if [[ $exp != "$foo" ]] @@ -1077,5 +1077,15 @@ do for word in '(word)' 'w(or)d' '(wor)d' 'w(ord)' 'w(ord' 'wor)d' done done +unset -v foo +for op in \? :\? +do for word in '(word)' 'w(or)d' '(wor)d' 'w(ord)' 'w(ord' 'wor)d' + do exp=$(set +x; eval "echo \${foo${op}${word}}" 2>&1) + if [[ $exp != *": foo: $word" ]] + then err_exit "\${foo${op}${word}} when foo is not set: expected *\": foo: $word\", got \"$exp\"" + fi + done +done + # ====== exit $((Errors<125?Errors:125))