help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Confused by =~ behavior with regards to quoting


From: Jean Delvare
Subject: [Help-bash] Confused by =~ behavior with regards to quoting
Date: Fri, 17 Oct 2014 11:37:47 +0200

Hi all,

I'm am confused by the behavior of the =~ operator with regards to
quoting, in particular the right hand side:

$ echo $BASH_VERSION
4.2.47(1)-release
$ [[ a =~ a ]] ; echo $?
0
$ [[ a =~ ^a ]] ; echo $?
0
$ [[ a =~ "a" ]] ; echo $?
0
$ [[ a =~ "^a" ]] ; echo $?
1

Can anyone explain that last failure to me? The third test suggests
that quoting the right hand side is allowed, so why does the fourth
test fail? Is this a bug?

I see the same with bash 3.2.51(1)-release on SLED11 SP3, and with a
self-built bash 4.3.30(1)-release, so it not specific to a version.

Thanks,
-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]