Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14304
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | marcelpaulo@gmail.com |
| Newsgroups | gnu.bash.bug |
| Subject | Word boundary anchors \< and \> not parsed correctly on the right side of =~ |
| Date | Mon, 09 Jul 2018 22:46:13 -0300 |
| Lines | 63 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.3347.1531187182.1292.bug-bash@gnu.org> (permalink) |
| NNTP-Posting-Host | lists.gnu.org |
| X-Trace | usenet.stanford.edu 1531187182 6934 208.118.235.17 (10 Jul 2018 01:46:22 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=message-id:date:from:to:subject; bh=cr61HxZnRrwR0Gbb9nCPvJ7vCMZKjHsVyj6jnp9n7tA=; b=npyoSKko78WcfWpR0Qd1zbXKnTMp78bLrVXnXBQyALzwgfINl0OQaMvDj5I6n1tpJm aXCAOAQ3W6J7ywj6WCYHLr97tvylfRANf9rNVtFqJL57t0JNxrBoPeeP3/M1qDtCj1IA m4fSxADRyrl6Rf6v8i34UUfKAp5grHgxx04dhg8ykqIIpN3WyUhJ/nbsGlJ4vNroXl0j d3+bjGVIHBTNsoKWOtiQ5dcT1GvKsXQPlGy4UgPq59HPSlATS2TNIgrPHOtPSijItFuC xoGM6npvBGyJTGh9zzMxJh6jhyWO6l3ooBe239sFZhC1yphK8KPmw0rCzK4THR5Z7UYL sLLg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:to:subject; bh=cr61HxZnRrwR0Gbb9nCPvJ7vCMZKjHsVyj6jnp9n7tA=; b=E2iD0TwsDHIIdNO3yLrW4rHNrAekrfQuvpQeY0kKBjNNcn/CPfhvIqgW0PjxUzL2rS HsZkFG7zbWeLFXavYU4izsaLX1fqWYH8/mezFPZniBRuinFlEP9UXAVgqwqP91eYB/7a 6FSpjXThR87z65tUr/EcKqYlBV4WWKcmhk59mjjs/CYKbgiRvaID4UbnX72k7AKcwF4v ByNviNVnGmkDMTEHgsyuhWq4XsB7DMBdFryArijoOhQw5IyRwm8uk2a8v3gp4gzBKnsI BcW1y4a98ocCB75OpsWhMoJeLKCJY+d7lSHElEv0+/ZrKtBv2Cj5qlWqtqpWb7oEwHPK W/Uw== |
| X-Gm-Message-State | APt69E0FxLe/DaGAUqN0eVIe40UjHqPfG+gKhrJX36o/ygmunbyvTcji op4pVHv1IckbW37to6oPKnI18Q== |
| X-Google-Smtp-Source | AAOMgpfCFXvjtgTU5N95GvREEj+LViOfeNdcEbkovGbIWnui444/I7/dDeVmlHbE8IK7mR65xqignw== |
| X-Received | by 2002:aed:36e7:: with SMTP id f94-v6mr21835125qtb.276.1531187177349; Mon, 09 Jul 2018 18:46:17 -0700 (PDT) |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:400d:c0d::236 |
| 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:14304 |
Show key headers only | View raw
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-vEMnMR/bash-4.4.18=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security
uname output: Linux monk 4.15.0-24-generic #26-Ubuntu SMP Wed Jun 13 08:44:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.4
Patch Level: 19
Release Status: release
Description:
Word boundary anchors \< and \> are not parsed correctly on the right side of a =~ regex match expression.
This evaluates as false:
[[ 'foo bar' =~ \<foo\> ]]
>From the bash reference manual:
An additional binary operator, ‘=~’, is available, with the same precedence
as ‘==’ and ‘!=’. When it is used, the string to the right of the operator
is consid- ered an extended regular expression and matched accordingly (as
in regex 3)).
Reading regex(3), I presumed the regexes would be parsed as C strings, so the
backslashes would need to be escaped:
[[ 'foo bar' =~ \\<foo\\> ]]
but this results in:
bash: syntax error in conditional expression: unexpected token `<'
bash: syntax error near `\\<f'
If the regex is stored in a variable, the expression evaluates as true:
re='\<foo\>'
[[ 'foo bar' =~ $re ]]
Treating the regex as C strings works for the \b anchor, so that this evaluates as true:
[[ 'foo bar' =~ \\bfoo\\b ]]
Repeat-By:
This is evaluated as false:
[[ 'foo bar' =~ \<foo\> ]]
but this evaluates as true:
re='\<foo\>'
[[ 'foo bar' =~ $re ]]
and this results in a syntax error:
[[ 'foo bar' =~ \\<foo\\> ]]
whereas this is parsed and evaluated correctly:
[[ 'foo bar' =~ \\bfoo\\b ]]
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Word boundary anchors \< and \> not parsed correctly on the right side of =~ marcelpaulo@gmail.com - 2018-07-09 22:46 -0300
csiph-web