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


Groups > gnu.bash.bug > #15381

Re: Incorrect example for `[[` command.

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Incorrect example for `[[` command.
Date Fri, 20 Sep 2019 08:48:27 -0400
Lines 30
Approved bug-bash@gnu.org
Message-ID <mailman.597.1568983749.2190.bug-bash@gnu.org> (permalink)
References <CAD0rTC7W20s7-8np7Z+CmZQczTQ+LX=Y1x01gAenewrpiJS5jw@mail.gmail.com> <20190920124827.GP28751@eeg.ccf.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1568983749 20270 209.51.188.17 (20 Sep 2019 12:49:09 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <CAD0rTC7W20s7-8np7Z+CmZQczTQ+LX=Y1x01gAenewrpiJS5jw@mail.gmail.com>
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 139.137.100.1
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
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 <https://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>
X-Mailman-Original-Message-ID <20190920124827.GP28751@eeg.ccf.org>
X-Mailman-Original-References <CAD0rTC7W20s7-8np7Z+CmZQczTQ+LX=Y1x01gAenewrpiJS5jw@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15381

Show key headers only | View raw


On Fri, Sep 20, 2019 at 01:40:00PM +0800, hk wrote:
> Description:
>         On section 3.2.4.2 of Bash Reference Manual, the example on*
> [[...]]* (page 13 in the PDF) is incorrect. Specifically, the example say *[[
> $line =~ [[:space:]]*?(a)b ]]*  will match values like *'aab'* and*
> 'aaaaaab*'. But it won't. The operator is* =~*, but the operand on the
> right side is a pattern while it should be a regular expression.

Nice catch.

Actually it's a mixture of a regular expression (the postfix * closure
operator) and an extended glob (the ?() enclosing syntax).  So it wouldn't
work with either = or =~ .

Even more subtly wrong, the sentence before the first instance of this
regex-glob-thing says:

  any number, including zero, of space characters, zero or one instances
  of ‘a’, then a ‘b’

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.

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


Thread

Re: Incorrect example for `[[` command. Greg Wooledge <wooledg@eeg.ccf.org> - 2019-09-20 08:48 -0400

csiph-web