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


Groups > gnu.bash.bug > #15385

Re: Incorrect example for `[[` command.

From Ilkka Virta <itvirta@iki.fi>
Newsgroups gnu.bash.bug
Subject Re: Incorrect example for `[[` command.
Date 2019-09-21 01:53 +0300
Message-ID <mailman.661.1569020030.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> <965d0fd5-c448-6724-a48d-dac6fda9ced0@iki.fi>

Show all headers | View raw


On 20.9. 21:39, Chet Ramey wrote:

> 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. 

Yeah, though the preceding paragraph contains both the general 
description of the regex match, and the mention of BASH_REMATCH, so the 
BASH_REMATCH angle could be a bit more explicit.

So I'd probably say that the pattern would match e.g. 'xxx aabyyy', or 
'xxxbyyy' and set $BASH_REMATCH to ' aab', or 'b', respectively. And 
then mention that the ^ and $ anchors could be used.

I know the usual regex behavior is to find a match anywhere within the 
value, but since it's exactly the opposite of how regular pattern 
matches work, it's probably worth mentioning in some way.  (Though I do 
think it's better to document things rather explicitly in general.)


-- 
Ilkka Virta / itvirta@iki.fi

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


Thread

Re: Incorrect example for `[[` command. Ilkka Virta <itvirta@iki.fi> - 2019-09-21 01:53 +0300

csiph-web