7 Bug-Reported-by: John Gatewood Ham <zappaman@buraphalinux.org>
8 Bug-Reference-ID: <Pine.LNX.4.64.0610121334140.15558@www.buraphalinux.org>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-10/msg00045.html
13 When using the conditional command's `=~' operator to match regular
14 expressions, the parser did not skip over shell metacharacters in the
15 regular expression, leading to syntax errors.
19 *** bash-3.2-patched/parse.y Tue Oct 17 11:45:20 2006
20 --- bash-3.2/parse.y Sat Oct 14 14:56:16 2006
24 #define PST_CMDTOKEN 0x1000 /* command token OK - unused */
25 #define PST_COMPASSIGN 0x2000 /* parsing x=(...) compound assignment */
26 #define PST_ASSIGNOK 0x4000 /* assignment statement ok in this context */
27 + #define PST_REGEXP 0x8000 /* parsing an ERE/BRE as a single word */
29 /* Initial size to allocate for tokens, and the
30 amount to grow them by. */
37 + if (parser_state & PST_REGEXP)
40 /* Shell meta-characters. */
41 if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
46 if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
50 /* Okay, if we got this far, we have to read a word. Read one,
51 and then check it against the known ones. */
52 result = read_token_word (character);
55 if (tok == WORD && test_binop (yylval.word->word))
57 #if defined (COND_REGEXP)
58 ! else if (tok == WORD && STREQ (yylval.word->word,"=~"))
61 else if (tok == '<' || tok == '>')
62 op = make_word_from_token (tok); /* ( */
64 if (tok == WORD && test_binop (yylval.word->word))
66 #if defined (COND_REGEXP)
67 ! else if (tok == WORD && STREQ (yylval.word->word, "=~"))
70 ! parser_state |= PST_REGEXP;
73 else if (tok == '<' || tok == '>')
74 op = make_word_from_token (tok); /* ( */
80 tok = read_token (READ);
81 + parser_state &= ~PST_REGEXP;
84 tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
91 /* Parse a ksh-style extended pattern matching specification. */
92 ! if (extended_glob && PATTERN_CHAR (character))
94 peek_char = shell_getc (1);
95 if MBTEST(peek_char == '(') /* ) */
101 + /* When parsing a regexp as a single word inside a conditional command,
102 + we need to special-case characters special to both the shell and
103 + regular expressions. Right now, that is only '(' and '|'. */ /*)*/
104 + if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
106 + if (character == '|')
107 + goto got_character;
109 + push_delimiter (dstack, character);
110 + ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
111 + pop_delimiter (dstack);
112 + if (ttok == &matched_pair_error)
113 + return -1; /* Bail immediately. */
114 + RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
115 + token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
116 + token[token_index++] = character;
117 + strcpy (token + token_index, ttok);
118 + token_index += ttoklen;
120 + dollar_present = all_digit_token = 0;
121 + goto next_character;
123 + #endif /* COND_REGEXP */
126 /* Parse a ksh-style extended pattern matching specification. */
127 ! if MBTEST(extended_glob && PATTERN_CHAR (character))
129 peek_char = shell_getc (1);
130 if MBTEST(peek_char == '(') /* ) */
132 *** bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
133 --- bash-3.2/patchlevel.h Mon Oct 16 14:22:54 2006
136 looks for to find the patch level (for the sccs version string). */
138 ! #define PATCHLEVEL 2
140 #endif /* _PATCHLEVEL_H_ */
142 looks for to find the patch level (for the sccs version string). */
144 ! #define PATCHLEVEL 3
146 #endif /* _PATCHLEVEL_H_ */