Meaning of “[–0]” in a glob pattern

wildcards

I was reading about "Glob" and "Globbing Pathnames", and I found this strange (to me) part in man pages:

"[–0]" matches the three characters '-', '.', '0', since '/' cannot be matched.

I am confused! How do two dashes and a 0 match .? What is the role of the / character here? Is this is a bug in man page?

Best Answer

As explained in the beginning of that paragraph in that man page, '-' character, when put between two characters, represents a range of characters, and also, '-' character, when put as first or last character between brackets, has its literal meaning. So, the first dash really means a '-' character, and the second dash is a range specifier. So the whole pattern consists of all the characters between '-' and '0', which, in the C/POSIX locale (but generally not in others) are:

-
.
/
0

and since '/' cannot be matched, the pattern matches three characters '-', '.', '0'.

Related Question