Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14307

Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~
Date Tue, 10 Jul 2018 08:27:18 -0400
Lines 23
Approved bug-bash@gnu.org
Message-ID <mailman.3365.1531225675.1292.bug-bash@gnu.org> (permalink)
References <5b440fe8.1c69fb81.948f6.4d1e@mx.google.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1531225677 28450 208.118.235.17 (10 Jul 2018 12:27:57 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org, bash@packages.debian.org
To marcelpaulo@gmail.com
Envelope-to bug-bash@gnu.org
Mail-Followup-To marcelpaulo@gmail.com, bug-bash@gnu.org, bash@packages.debian.org
Content-Disposition inline
In-Reply-To <5b440fe8.1c69fb81.948f6.4d1e@mx.google.com>
User-Agent NeoMutt/20170113 (1.7.2)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 139.137.100.1
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14307

Show key headers only | View raw


On Mon, Jul 09, 2018 at 10:46:13PM -0300, marcelpaulo@gmail.com wrote:
> Word boundary anchors \< and \> are not parsed correctly on the right side of a =~ regex match expression. 

Bash uses ERE (Extended Regular Expressions) here.  There is no \< or \>
in an ERE.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04

> This evaluates as false:
> 
>     [[ 'foo bar' =~ \<foo\> ]]

Well, of course it does, because \< is just a literal less-than sign
in a POSIX ERE.

wooledg:~$ re='\<foo\>'
wooledg:~$ [[ '<foo>' =~ $re ]] && echo yes
yes

You might as well remove the backslashes, because they serve no purpose
here.  If you thought they meant "word boundary" or something, you're
in the wrong language.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~ Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-10 08:27 -0400

csiph-web