original-mawk
original-mawk copied to clipboard
mawk mishandles {2,} in regular expressions
I found this problem while trying to use mawk to implement tzselect, an awk-using program that's part of tzcode. To reproduce the bug, run this shell command:
mawk 'BEGIN { if ("aaa" ~ /^a{2,}$/) print "ok" }'
This should output "ok" but does not, because the regular expression ^a{2,}$
incorrectly matches only aa
.
I found the problem on mawk 1.3.4 20230730 as distributed by Ubuntu 23.10. The problem is still present in mawk 1.3.4 20231126 which I compiled myself.
thanks - will fix. I understand the problem, but won't get to this for a few weeks (currently improvements to mawk are behind several other programs).
mawk 'BEGIN { if ("aaa" ~ /^a{2,5}$/) print "ok" }'
fails as well
This doesn't look right either.
$ echo 'x xx ' | mawk '{sub(/(x+ +){2}/, "y")} 1'
yxx