Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Greg Wooledge 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: References: <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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20190920124827.GP28751@eeg.ccf.org> X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:15381 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.