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


Groups > gnu.bash.bug > #15384

Re: Incorrect example for `[[` command.

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Incorrect example for `[[` command.
Date 2019-09-20 14:39 -0400
Message-ID <mailman.628.1569004797.2190.bug-bash@gnu.org> (permalink)
References <CAD0rTC7W20s7-8np7Z+CmZQczTQ+LX=Y1x01gAenewrpiJS5jw@mail.gmail.com> <20190920124827.GP28751@eeg.ccf.org> <70f5667e-d91e-a4cf-fef0-b72c7d61a29a@iki.fi> <322f128f-0f7d-064c-2e47-baed38cb7493@case.edu>

Show all headers | View raw


On 9/20/19 9:30 AM, Ilkka Virta wrote:
> On 20.9. 15:48, Greg Wooledge wrote:
>> but after the regex-glob-thing, it says:
>>
>>    That means values like ‘aab’ and ‘ aaaaaab’ will match
>>
>> So there's a shift in intent between a? and a+ in what's supposed to be
>> a regular expression.  Although of course the sentence is *literally*
>> true because the regex would be unanchored, and therefore it's sufficient
>> to match only the 'ab', and the rest of the input doesn't matter.
>> But that's just confusing, and doesn't belong in this kind of document.
> 
> It goes on to say "as will a line containing a 'b' anywhere in its value",
> so the text does recognize the zero-width-matching parts don't affect what
> matches. (I suppose they would affect what goes to BASH_REMATCH[0], but the
> text doesn't mention that.)

The portion of the manual before the example explains BASH_REMATCH and
BASH_REMATCH[0]. It also says "a sequence of characters in the value..."
when describing the pattern. This is the usual behavior of regcomp/regexec
(and grep/egrep, for that matter, since grep will print lines when a
substring matches the supplied pattern).

> I think it would be a better example with the anchored version also
> presented for comparison.

How about saying you can anchor the match with the usual ^ and $ special
pattern characters?

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

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


Thread

Re: Incorrect example for `[[` command. Chet Ramey <chet.ramey@case.edu> - 2019-09-20 14:39 -0400

csiph-web