Subject: Re: bug#15410: [:alnum:] is not [:alpha:] AND [:digit:]... [:alnum:] is [:alpha:] OR [:digit:]

From: Eric Blake <[email-masked]>
Date: Wed, 18 Sep 2013 14:14:55 -0600

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