[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash-4.3-rc2 available for FTP
From: |
Mike Frysinger |
Subject: |
Re: Bash-4.3-rc2 available for FTP |
Date: |
Thu, 30 Jan 2014 16:00:21 -0500 |
User-agent: |
KMail/4.12.1 (Linux/3.13.0; KDE/4.12.1; x86_64; ; ) |
On Thursday, January 30, 2014 10:48:34 Chet Ramey wrote:
> o. The shell now handles backslashes in regular expression arguments to the
> [[ command's =~ operator slightly differently, resulting in more
> consistent behavior.
hmm, i seem to be running into a bug here. the bash man page suggests that
the behavior should match regex(3), but it doesn't seem to. consider:
$ cat doit.sh
v="a\-b"
[[ ! a-b =~ ${v} ]]
: $?
# This is expected behavior.
$ bash-4.2_p45 -x ./doit.sh
+ v='a\-b'
+ [[ ! a-b =~ a\-b ]]
+ : 1
# This is unexpected behavior.
$ bash-4.3_rc2 -x ./doit.sh
+ v='a\-b'
+ [[ ! a-b =~ a\\-b ]]
+ : 0
compare that to regex(3) behavior:
$ cat test.c
#include <stdio.h>
#include <regex.h>
int main(int argc, char *argv[]) {
regex_t preg;
int i1 = regcomp(&preg, argv[1], 0);
int i2 = regexec(&preg, argv[2], 0, NULL, 0);
printf("regcomp(%s) = %i\n"
"regexec(%s) = %i\n", argv[1], i1, argv[2], i2);
return 0;
}
$ gcc test.c
$ ./a.out 'a\-b' a-b
regcomp(a\-b) = 0
regexec(a-b) = 0
it had no problem matching ...
-mike
signature.asc
Description: This is a digitally signed message part.