serious awk bug
Tom Stockfisch
tps at chem.ucsd.edu
Wed Mar 14 16:02:46 AEST 1990
The following awk script doesn't behave properly:
#! /bin/sh
awk '/^a*[^b]/ { print "1:", $0 }
/^a*b/ { print "2:", $0 }
'
When given the following input
b
ab
It produces the following output
2: b
1: ab
2: ab
Basically, the line "ab" should match only rule 2, but it matches both
rules. The following script:
#! /bin/sh
awk '/^a*[^b]c/ { print "1:", $0 }
/^a*bc/ { print "2:", $0 }
'
works, producing the output
2: bc
2: abc
The corresponding lex program works fine.
I have run the awk script with both the new awk and old awk, on both
a system V machine (silicon graphics iris) and a 4BSD machine (celerity)
and all seem to fail.
--
|| Tom Stockfisch, UCSD Chemistry tps at chem.ucsd.edu
More information about the Comp.unix.wizards
mailing list