Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14309
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Paulo Marcel Coelho Aragão <marcelpaulo@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~ |
| Date | Tue, 10 Jul 2018 10:02:34 -0300 |
| Lines | 38 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.3368.1531227765.1292.bug-bash@gnu.org> (permalink) |
| References | <5b440fe8.1c69fb81.948f6.4d1e@mx.google.com> <20180710122718.wrrzjuqpmpns4o4o@eeg.ccf.org> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | usenet.stanford.edu 1531227765 29373 208.118.235.17 (10 Jul 2018 13:02:45 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org, bash@packages.debian.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qgt+jP22M9A3bR5hfZc1y+4Jj1cIpzCYtOKoyBVG9ko=; b=YaRgCiATd5lkOSPFYMLsKHdN5cWF/YCfBq7RYzu+6DPaCUr8O8AqyZaJ37GeAUTYsn 10KxuEjPvxw+yRGjS2rh1E4jo1YZlZsxP7CA3zjbW94EG5htYnjsuhTy2Ork0sqtQlXo 0XyBURYyXH2MRFnL0GWJkCaUdgr+2ySqUzuvPjnxMwnxzbCf+fMqxsLrSL1S9jEuFEg5 +1Yqu6+++nY5x+69ZSrCzcj85KiyRjNTwHVcGOrOdKLRG3TsaQ6wwwkWkxYAVlN8OKjx Vb0qcEr8iKL6xjT58poO8s71hkpJxSeXNJbplDvqBZhOyBxUdvZ/PIvSMdp+tW5pLFS/ y6fQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qgt+jP22M9A3bR5hfZc1y+4Jj1cIpzCYtOKoyBVG9ko=; b=IpvOAQGpzVb6EB6PxV9yikGSJr8tuYqyStOx1izfMXfVkZY+sEXf4Jh/kGXnVnXtMf 2Pk4K8j1hUqMmezE3hE19JG+yFqeRvGhad+oJTcHFIQmyak/ot32/T9iH0a054E5UnUf SBeG/B/N1W524fVfCK0W5EubDW59oKCLBCYbSwfmJp4HEE7wO5WlE64PkKySkXAVxGEz rIcG0v/52LsdSa9VMNWBhR4NEG6rSps02pTtab8aVXyQKu7b4QhYUcpvqxwD9anrPkIu pdJJ9dgPYSJoxvDxCPNHSd3HZ+3rFX6NEvJUTZvCMbYjctgsvLi0WYzS0F7MkZyE+V8M hDWw== |
| X-Gm-Message-State | AOUpUlFe9T3jEmY0bzY7rBUjeBtyJ9014w3YFk6h0i4WbhKfhd7aeIlQ YYh3ywIO0aClywJYpiOxrvyeyw== |
| X-Google-Smtp-Source | AAOMgpcn55z5ulApzhaFJ3jEIwJYgf7joDDnfxXClgozmmkPFHe/E9UPEosih7yQ5Wp3/RcLv6Va9w== |
| X-Received | by 2002:a0c:d842:: with SMTP id i2-v6mr2343227qvj.77.1531227756860; Tue, 10 Jul 2018 06:02:36 -0700 (PDT) |
| Content-Disposition | inline |
| In-Reply-To | <20180710122718.wrrzjuqpmpns4o4o@eeg.ccf.org> |
| User-Agent | NeoMutt/20171215 |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:400d:c0d::232 |
| 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:14309 |
Show key headers only | View raw
On Tue, Jul 10, 2018 at 08:27:18AM -0400, Greg Wooledge wrote:
> 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
Thanks for the reference. The document lists only ^ and $ as anchors. However, this indicates to me that bash recognizes \< \> as word anchors:
paulo:~$ re='\<foo\>'
paulo:~$ [[ 'foo bar' =~ $re ]] && echo yes || echo no
yes
paulo:~$ [[ 'foobar' =~ $re ]] && echo yes || echo no
no
It baffles me that literal \< \> are not evaluated correctly
paulo:~$ [[ 'foo bar' =~ \<foo\> ]] && echo yes || echo no
no
This indicates that bash also recognizes \b as word anchor:
paulo:~$ re='\bfoo\b'
paulo:~$ [[ 'foo bar' =~ $re ]] && echo yes || echo no
yes
paulo:~$ [[ 'foobar' =~ $re ]] && echo yes || echo no
no
but it also baffles me literal \b is not evaluated correctly:
paulo:~$ [[ 'foo bar' =~ \bfoo\b ]] && echo yes || echo no
no
Empirically all this demonstrates:
1. bash recognizes \< \> \b as word anchors
2. bash doesn't evaluate them correctly when used as literals
3. bash evaluates them correctly when used with parameter expansion
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~ Paulo Marcel Coelho Aragão <marcelpaulo@gmail.com> - 2018-07-10 10:02 -0300
csiph-web