Luca Berra:
> >What I describe is not list notation. Specifically, the glob {1,2,11}
> >means 1 AND 2 AND 11, while the pattern [1,2,11] means 1 OR 2 OR 11.
> >
> > $ echo {1,2,11}
> > 1 2 11
> > $ echo {1..11}
> > 1 2 3 4 5 6 7 8 9 10 11
> >
> >If we want to avoid confusion, then we should not use AND notation
> >in places where OR operation is intended.
>
> I understand that from you point of view you are
> formally correct.
> specifically because in shells brace expansion is not really related to
> filename globbing.
>
> but i was looking at it the other way around, so i see 1,2,11 as a
> _list_ of possible matches
>
> it is just a question of ergonomics, in either case we are overriding a
> syntax (or using a syntax with some similarities to another), which one
> will be clearer to the end user?
>
> {1,2,11} and [1,2,11] are both clear
I think that the "," is a hint that [n,m] is a sequence. I'm sure
that (n,m) would also be clear (familiar idiom to Perl users).
The {n,m} form is familiar in BASH (and other shell) context, while
the [n,m] form requires a little user education (not necessarily
bad, since address patterns are clearly unlike BASH-like context).
> what about [12-45] versus {12..45} ?
Better: what about [12..45]? I think that nails it pretty well as
far as clarity is concerned.
In regexp and pcre, {} is used as a quantifier, such that stuff{n,m}
means "at least n and at most m instances of stuff". It does not
define a sequence of n, n+1, n+2, ..., m as in BASH.
Although the form {n,m} as shorthand for n, n+1, n+2, ..., m is
familiar to BASH users, this could still result in confusion,
because Postfix address patterns are not BASH compatible without
support for x..y..z. The worst part of compatibility is where is
lets you down.
On the other hand, almost no-one would be confused when Postfix
address patterns were to use (n..m), not even the people who know
this idiom from Perl.
Both (n,m) and [n,m] may confuse some mathematicians who expect
that [n,m] is a closed interval while (n,m) is an open interval.
So we need user education regardless of what is used.
- The [n,m] and [n..m] notation is not familiar, but the "," and
".." are clear. It is unlikely to confuse people with false
expectations when they are familiar with other systems (except
mathematicians).
- The {n,m} and {n..m} notation handicaps some BASH users with
false expectations because Postfix behavior is not identical to
BASH behavior. It also conflicts with pattern matching, where
{n,m} is used as a quantifier.
- The (n,m) and (n..m) notation is familiar to Perl users, and
does not handicap them with false expectations. (though it
is non-intuitive from a mathematician's point of view).
I'm inclined to go for "clarity": [n,m] and [n..m]. With this
choice, no-one suffers from false expectations. Anyone can understand
that "n,m" means a sequence of n and m, and anyone can understand
that "n..m" means a range from n to m.
Wietse