Andreas Schwab wrote: > Wacek Kusnierczyk <[email protected]> writes: > > >> if, as you seem to imply, the pattern is 'a non-backslash followed by a >> closing bracket', then >> - the rightmost closing bracket is *outside* of any class (the class >> [^\] has been closed), thus >> > > Right. > > >> - it is (should be) a *metacharacter*, and and as such >> > > Wrong. > > >> - it must be taken as *closing a class*, which is not there and it >> neither should match the closing bracket in the data (which it does in >> some of the other examples) >> > > The ']' character is only special when part of a bracket expression. In > all other contexts it just matches itself. > >
oh my. right, thanks, this did not occur to me. i suspected this is what happens, but from what i read about bre, it was clear that both [ and ] are special characters, and thus the idea that an unpaired ] outside of any class be taken literally seemed wrong. this is surely documented, but i could only find, in various sources, statements and examples to the effect that both [ and ] are metacharacters, and that ] is taken literally when it's the first character within a class. it could probably be taken as obvious that an unpaired ] is literal, but then the following seems a bit incoherent: egrep -o ']' <<< ']' # ] egrep 'o ')' <<< ')' # egrep: unmatched ) or \) why couldn't unmatched ) be taken literally too? thanks for bearing with my silly questions. vQ
