7 Bug-Reported-by: Ryan Waldron <rew@erebor.com>
8 Bug-Reference-ID: <20070119065603.546D011E9C@kansas.erebor.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00059.html
13 The glibc implementation of regcomp/regexec does not allow backslashes to
14 escape "ordinary" pattern characters when matching. Bash used backslashes
15 to quote all characters when the pattern argument to the [[ special
16 command's =~ operator was quoted. This caused the match to fail on Linux
17 and other systems using GNU libc.
21 *** ../bash-3.2.9/pathexp.h Sat Feb 19 17:23:18 2005
22 --- bash-3.2/pathexp.h Wed Jan 31 22:53:16 2007
25 /* pathexp.h -- The shell interface to the globbing library. */
27 ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
29 This file is part of GNU Bash, the Bourne Again SHell.
31 /* pathexp.h -- The shell interface to the globbing library. */
33 ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
35 This file is part of GNU Bash, the Bourne Again SHell.
39 #define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */
40 #define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */
41 + #define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
43 #if defined (EXTENDED_GLOB)
44 *** ../bash-3.2.9/pathexp.c Mon May 6 13:43:05 2002
45 --- bash-3.2/pathexp.c Mon Feb 26 16:59:23 2007
48 /* pathexp.c -- The shell interface to the globbing library. */
50 ! /* Copyright (C) 1995-2002 Free Software Foundation, Inc.
52 This file is part of GNU Bash, the Bourne Again SHell.
54 /* pathexp.c -- The shell interface to the globbing library. */
56 ! /* Copyright (C) 1995-2007 Free Software Foundation, Inc.
58 This file is part of GNU Bash, the Bourne Again SHell.
64 + /* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
65 + be quoted to match itself. */
91 /* PATHNAME can contain characters prefixed by CTLESC; this indicates
92 that the character is to be quoted. We quote it here in the style
96 if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
98 + if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
102 *** ../bash-3.2.9/subst.c Tue Nov 7 16:14:41 2006
103 --- bash-3.2/subst.c Wed Jan 31 23:09:58 2007
106 beauty, but, hey, you're alright.'' */
108 ! /* Copyright (C) 1987-2006 Free Software Foundation, Inc.
110 This file is part of GNU Bash, the Bourne Again SHell.
112 beauty, but, hey, you're alright.'' */
114 ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
116 This file is part of GNU Bash, the Bourne Again SHell.
119 /* This needs better error handling. */
120 /* Expand W for use as an argument to a unary or binary operator in a
121 ! [[...]] expression. If SPECIAL is nonzero, this is the rhs argument
122 to the != or == operator, and should be treated as a pattern. In
123 ! this case, we quote the string specially for the globbing code. The
124 ! caller is responsible for removing the backslashes if the unquoted
125 ! words is needed later. */
127 cond_expand_word (w, special)
129 /* This needs better error handling. */
130 /* Expand W for use as an argument to a unary or binary operator in a
131 ! [[...]] expression. If SPECIAL is 1, this is the rhs argument
132 to the != or == operator, and should be treated as a pattern. In
133 ! this case, we quote the string specially for the globbing code. If
134 ! SPECIAL is 2, this is an rhs argument for the =~ operator, and should
135 ! be quoted appropriately for regcomp/regexec. The caller is responsible
136 ! for removing the backslashes if the unquoted word is needed later. */
138 cond_expand_word (w, special)
146 if (w->word == 0 || w->word[0] == '\0')
152 ! r = quote_string_for_globbing (p, QGLOB_CVTNULL);
158 + qflags = QGLOB_CVTNULL;
160 + qflags |= QGLOB_REGEXP;
162 ! r = quote_string_for_globbing (p, qflags);
165 *** ../bash-3.2.9/execute_cmd.c Sat Aug 26 00:23:17 2006
166 --- bash-3.2/execute_cmd.c Wed Jan 31 23:12:06 2007
169 /* execute_cmd.c -- Execute a COMMAND structure. */
171 ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
173 This file is part of GNU Bash, the Bourne Again SHell.
175 /* execute_cmd.c -- Execute a COMMAND structure. */
177 ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
179 This file is part of GNU Bash, the Bourne Again SHell.
184 ! arg2 = cond_expand_word (cond->right->op, patmatch||rmatch);
190 ! arg2 = cond_expand_word (cond->right->op, rmatch ? 2 : (patmatch ? 1 : 0));
193 *** ../bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
194 --- bash-3.2/patchlevel.h Mon Oct 16 14:22:54 2006
197 looks for to find the patch level (for the sccs version string). */
199 ! #define PATCHLEVEL 9
201 #endif /* _PATCHLEVEL_H_ */
203 looks for to find the patch level (for the sccs version string). */
205 ! #define PATCHLEVEL 10
207 #endif /* _PATCHLEVEL_H_ */