GNU bug report logs - #15410
[:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:]

Previous Next

Package: grep;

Reported by: Nick Aganan <thesysad <at> gmail.com>

Date: Wed, 18 Sep 2013 16:13:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #18 received at 15410 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Nix <thesysad <at> gmail.com>, 15410 <at> debbugs.gnu.org
Subject: Re: bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:]
 is [:alpha:] OR [:digit:]
Date: Wed, 18 Sep 2013 14:14:55 -0600
[Message part 1 (text/plain, inline)]
On 09/18/2013 01:56 PM, Nix wrote:

Please keep the list in the loop:
https://rwmj.wordpress.com/2010/11/08/want-help-dont-email-me-directly/

> The documentation is wrong then...
> When you say "AND" that means you need to satisfy "ALL" entity before it
> exit successfully.
> Using OR is fitted in your description. OR satisfies "ALL" or "EITHER" to
> have a  successful exit.
> 
> Bottom line, it is about the logic of using AND or OR.

It's about WHERE you are using the logic of AND or OR.  Let's try again.
 If I write:

[@[:alnum:]!]

then I have a bracket expression containing three elements: [:alnum:],
@, and !, which is the SAME as if I had written the bracket expression

[@[:alpha:][:digit:]!]

or even

[[:digit:]!@[:alpha:]]

Either way, I'm using [:alnum:] as shorthand instead of including both
[:alpha:] AND [:digit:].  Then, the resulting bracket expression matches
one byte that can come from a set of characters: @, !, alpha OR digit.
It is the outer bracket expression that is doing OR matching, while the
inner [:alnum:] element within the bracket expression is representing
AND-based combination shorthand of other possible bracket expression
elements.

Similarly, [@!] is a bracket expression containing @ AND ! as expression
elements, where the overall expression will then match @ OR !.  But as @
matches only one possible character, rather than being shorthand for a
bunch of characters, you don't get as confused by that wording.

If you want to propose a documentation patch to make it clearer for the
next reader, then by all means do so.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 11 years and 304 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.