Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: hk Newsgroups: gnu.bash.bug Subject: Re: Incorrect example for `[[` command. Date: Sat, 21 Sep 2019 08:12:56 +0800 Lines: 53 Approved: bug-bash@gnu.org Message-ID: References: <8e7c8ea4-2fdf-4809-0b50-ea1bfbbec165@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1569024793 15256 209.51.188.17 (21 Sep 2019 00:13:13 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: chet.ramey@case.edu Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xlamOJ/Z3zLmuMFU+US+j2MGaXdvp8uGRd1yTmzqQeY=; b=XTYzbgXzaLlrNY+3Ppi8LgIKeMsRzfEmI5SiVJohEMem0tXJtMQymGB0q9f0uKYq2J JBowz01bXm0Wca0kk9kvW7yB9ZGaHu+/uCh/iHTom08SrJB0S3/q3Hcr0a57lKJ7bjae lDqhwCY1pGuvd6iFxoUpRskscG9g/biv+cSjn7OtMP1zeJnUfczJaUZ7HE1IZd9C6U/x QlDIwWl7YA6tBh4vmObGQpgWW16R7q1LU6yE/nAsdAxrx2NkW4/7K43+Wu6KiqktxZ6R DLLi/tya+8Pkwr5O+1JdHgmXDGLZwVYE+5MtUyruU37STFXDuwg+rSfX3XzYA1a4hlId 1yJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xlamOJ/Z3zLmuMFU+US+j2MGaXdvp8uGRd1yTmzqQeY=; b=ljDhJEQcDYkcRgDzduxnTwM5njfj0hiLruzlHZvENc/AHQeitTxszmzH9jWHf93Ke/ BlbeYw/tMLyfOZEQ5B5CdtUTBLZCb3vqXmAbrcq5p1IGdTKkEPGd0jy8uSAv3L5biCEh /TsNS/YXDzaJwSXCG6ucsxr/tNnuuAuhLZh3PouiQVJSo4gyBDbLCgzHWaZARgQHl4Xv JuM1pEo1WfsLTDOnfAop2XaFFcPApBZmyYlVtWcNxuAVj3OsW/tZj+DcfB+LyaQoIxnh 00gDNUq3jVlqQzbo58zwlUEcEkt0p9Bjd1LqKpmlL1c8JhI4i8PIaxkqwfCN4xgLwzMu 32YA== X-Gm-Message-State: APjAAAWWj+pj5nV25q1xXbgglI4sY0xQkvDWlEyg7fqje8GvE586aY5J t7jza/C4zRNnrv2PpVc3Y8f1J5ZWMn/rqaxHIZg= X-Google-Smtp-Source: APXvYqyr7d53X6myR8peYmcKPXsG4sYL/GRvVws6M3oXlwq2NpgXIbvfQWplbCkYukvN+NOgQSDa9o5PV23Zq5uqPrc= X-Received: by 2002:ac8:5357:: with SMTP id d23mr6297778qto.223.1569024788137; Fri, 20 Sep 2019 17:13:08 -0700 (PDT) In-Reply-To: <8e7c8ea4-2fdf-4809-0b50-ea1bfbbec165@case.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::831 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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: X-Mailman-Original-References: <8e7c8ea4-2fdf-4809-0b50-ea1bfbbec165@case.edu> Xref: csiph.com gnu.bash.bug:15386 Thanks for the reply. I was wrong in my report. It does match values like aab and aaaaaab in its original form. What is wrong is the description `zero or one instances of 'a''. But if we correct the right hand side word to be `[[:space:]]*(a)?b' that it does match what the description says.(the parenthese around `a' could be omitted). I was also wrong saying it was a pattern instead of a regular expression. It is syntatically correct as a regular expression. A word can be syntactically correct as a pattern and a regular expression at the same time though the semantic might be different in most cases. On Fri, Sep 20, 2019 at 11:48 PM Chet Ramey wrote: > On 9/20/19 1:40 AM, hk wrote: > > > Bash Version: 5.0 > > Patch Level: 0 > > Release Status: release > > > > 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. > > Thanks for the report, this is a good catch. It's been this way since 2011. > > It's supposed to be a regular expression, and there's a typo. You're right > that it doesn't match the same things as if it were interpreted as a shell > pattern. > > The pattern would match the description if it were `[[:space:]]*(a)?b'. > > The pattern, once corrected, does match the strings in the example below, > since, as the description says, it matches "a sequence of characters in the > value." > > The regexp is unanchored, though you can anchor it yourself. That's > arguably less useful than the anchored case (like, say, grep), but that's > what you get from regcomp/regexec, and you have $BASH_REMATCH to see what > you matched. > > 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/ >