parse “$( (( … ) … ) … )” correctly (LP#1532621)

This commit is contained in:
tg 2016-01-14 19:52:20 +00:00
parent 2492c5692b
commit 0a1f594503
2 changed files with 7 additions and 4 deletions

6
lex.c
View File

@ -2,7 +2,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015
* 2011, 2012, 2013, 2014, 2015, 2016
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.214 2015/12/12 19:05:52 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.215 2016/01/14 19:52:20 tg Exp $");
/*
* states while lexing word
@ -777,6 +777,7 @@ yylex(int cf)
Source *s;
ungetsc(c2);
ungetsc(c);
/*
* mismatched parenthesis -
* assume we were really
@ -789,6 +790,7 @@ yylex(int cf)
s->start = s->str = s->u.freeme = dp;
s->next = source;
source = s;
ungetsc('('/*)*/);
return ('('/*)*/);
}
} else if (c == '(')

5
syn.c
View File

@ -2,7 +2,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009,
* 2011, 2012, 2013, 2014, 2015
* 2011, 2012, 2013, 2014, 2015, 2016
* mirabilos <m@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.107 2015/12/12 21:03:53 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.108 2016/01/14 19:52:20 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -400,6 +400,7 @@ get_command(int cf)
case LWORD:
break;
case '(': /*)*/
c = '(';
goto Subshell;
default:
syntaxerr(NULL);