mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-10 04:00:34 +02:00
commit bash-20050922 snapshot
This commit is contained in:
@@ -2709,6 +2709,7 @@ read_token (command)
|
||||
#define P_FIRSTCLOSE 0x01
|
||||
#define P_ALLOWESC 0x02
|
||||
#define P_DQUOTE 0x04
|
||||
#define P_COMMAND 0x08 /* parsing a command, so look for comments */
|
||||
|
||||
static char matched_pair_error;
|
||||
static char *
|
||||
@@ -2717,13 +2718,14 @@ parse_matched_pair (qc, open, close, lenp, flags)
|
||||
int open, close;
|
||||
int *lenp, flags;
|
||||
{
|
||||
int count, ch, was_dollar;
|
||||
int count, ch, was_dollar, in_comment, check_comment;
|
||||
int pass_next_character, nestlen, ttranslen, start_lineno;
|
||||
char *ret, *nestret, *ttrans;
|
||||
int retind, retsize, rflags;
|
||||
|
||||
count = 1;
|
||||
pass_next_character = was_dollar = 0;
|
||||
pass_next_character = was_dollar = in_comment = 0;
|
||||
check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
|
||||
|
||||
/* RFLAGS is the set of flags we want to pass to recursive calls. */
|
||||
rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
|
||||
@@ -2751,6 +2753,21 @@ parse_matched_pair (qc, open, close, lenp, flags)
|
||||
if (ch == '\n' && SHOULD_PROMPT ())
|
||||
prompt_again ();
|
||||
|
||||
if (in_comment)
|
||||
{
|
||||
/* Add this character. */
|
||||
RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
|
||||
ret[retind++] = ch;
|
||||
|
||||
if (ch == '\n')
|
||||
in_comment = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
/* Not exactly right yet */
|
||||
else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1])))
|
||||
in_comment = 1;
|
||||
|
||||
if (pass_next_character) /* last char was backslash */
|
||||
{
|
||||
pass_next_character = 0;
|
||||
@@ -2873,7 +2890,7 @@ add_nestret:
|
||||
}
|
||||
FREE (nestret);
|
||||
}
|
||||
else if MBTEST(qc == '`' && (ch == '"' || ch == '\''))
|
||||
else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
|
||||
{
|
||||
nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
|
||||
goto add_nestret;
|
||||
@@ -3363,7 +3380,7 @@ read_token_word (character)
|
||||
if MBTEST(shellquote (character))
|
||||
{
|
||||
push_delimiter (dstack, character);
|
||||
ttok = parse_matched_pair (character, character, character, &ttoklen, 0);
|
||||
ttok = parse_matched_pair (character, character, character, &ttoklen, (character == '`') ? P_COMMAND : 0);
|
||||
pop_delimiter (dstack);
|
||||
if (ttok == &matched_pair_error)
|
||||
return -1; /* Bail immediately. */
|
||||
@@ -3426,7 +3443,7 @@ read_token_word (character)
|
||||
history literally rather than causing a possibly-
|
||||
incorrect `;' to be added. ) */
|
||||
push_delimiter (dstack, peek_char);
|
||||
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
|
||||
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, P_COMMAND);
|
||||
pop_delimiter (dstack);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user