- 论坛徽章:
- 0
|
原帖由 woodie 于 2006-12-15 11:35 发表
这个还真的不是BUG,bash这样只是为了更加符合POSIX标准。
这句说的对。
至于为什么bash会这么扩展,请看从man bash中摘抄的内容:
[...] Matches any one of the enclosed characters. A pair of charac-
ters separated by a hyphen denotes a range expression; any char-
acter that sorts between those two characters, inclusive, using
the current locale’s collating sequence and character set, is
matched. If the first character following the [ is a ! or a ^
then any character not enclosed is matched. The sorting order
of characters in range expressions is determined by the current
locale and the value of the LC_COLLATE shell variable, if set.
A - may be matched by including it as the first or last charac-
ter in the set. A ] may be matched by including it as the first
character in the set.
注意这里所说的sort
看到这里,大家明白为什么默认情况下bash的[a-z]会扩展出大写字符了吧?
PS:给网中人兄的十三问挑个错,[!...]和[^...]并非Wildcard 与 Regular Expression 的差別,事实上,可以认为它们并无差别。在这个语境里,它们都是Wildcard的部分,而且扩展效果也没有任何不同。网中人那篇文章整体没错,但文章题目似乎有误。 |
|