Apparently, a bracket expression in BSD Awk which contains a character class will ignore any further characters after the character class:
MacOS $ cat file.txt
_
-
.
a
B
8
:
;
@
~
,
MacOS $ awk '/[@~.[:alnum:]:;-]/' file.txt
.
a
B
8
@
~
MacOS $ awk '/[-;:@~.[:alnum:]]/' file.txt
-
.
a
B
8
:
;
@
~
MacOS $ awk '/[^@~.[:alnum:]:;-]/' file.txt
_
-
:
;
,
MacOS $ awk '/[^-;:@~.[:alnum:]]/' file.txt
_
,
MacOS $
On GNU Awk (shown on Ubuntu 16.04), the behavior is different; other characters in the bracket expression are handled the same regardless of whether they come before or after the character class:
Linux $ cat file.txt
_
-
.
a
B
8
:
;
@
~
,
Linux $ awk '/[@~.[:alnum:]:;-]/' file.txt
-
.
a
B
8
:
;
@
~
Linux $ awk '/[-;:@~.[:alnum:]]/' file.txt
-
.
a
B
8
:
;
@
~
Linux $ awk '/[^@~.[:alnum:]:;-]/' file.txt
_
,
Linux $ awk '/[^-;:@~.[:alnum:]]/' file.txt
_
,
Linux $
Is this documented anywhere? Or, if it is a bug, is it a known bug? (And if it is a known bug, is it fixed in later versions of Awk?)
What should I do with this discovery? Is there somewhere I should open a bug report?