commit bash-20050707 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:48:19 -05:00
parent da71998238
commit fd3925f15a
23 changed files with 6148 additions and 1069 deletions
+10 -15
View File
@@ -2703,9 +2703,8 @@ read_token (command)
/*
* Match a $(...) or other grouping construct. This has to handle embedded
* quoted strings ('', ``, "") and nested constructs. It also must handle
* reprompting the user, if necessary, after reading a newline (unless the
* P_NONL flag is passed), and returning correct error values if it reads
* EOF.
* reprompting the user, if necessary, after reading a newline, and returning
* correct error values if it reads EOF.
*/
#define P_FIRSTCLOSE 0x01
#define P_ALLOWESC 0x02
@@ -2852,6 +2851,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
else if MBTEST(open == '"' && ch == '`')
{
nestret = parse_matched_pair (0, '`', '`', &nestlen, rflags);
add_nestret:
if (nestret == &matched_pair_error)
{
free (ret);
@@ -2865,6 +2865,11 @@ parse_matched_pair (qc, open, close, lenp, flags)
}
FREE (nestret);
}
else if MBTEST(qc == '`' && (ch == '"' || ch == '\''))
{
nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
goto add_nestret;
}
else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
/* check for $(), $[], or ${} inside quoted string. */
{
@@ -2876,18 +2881,8 @@ parse_matched_pair (qc, open, close, lenp, flags)
nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags);
else if (ch == '[') /* ] */
nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
if (nestret == &matched_pair_error)
{
free (ret);
return &matched_pair_error;
}
if (nestlen)
{
RESIZE_MALLOCED_BUFFER (ret, retind, nestlen, retsize, 64);
strcpy (ret + retind, nestret);
retind += nestlen;
}
FREE (nestret);
goto add_nestret;
}
was_dollar = MBTEST(ch == '$');
}