goawk
goawk copied to clipboard
Support for %i in format strings.
The POSIX spec permits using %i as an alternative to %d. This is supported by most awk implementations:
% awk 'BEGIN{printf("%i\n",42)}'
42
% mawk 'BEGIN{printf("%i\n",42)}'
42
% gawk 'BEGIN{printf("%i\n",42)}'
42
GoAWK v1.27.0 does not interpret %i correctly:
% goawk 'BEGIN{printf("%i\n",42)}'
%!i(int=42)
Thanks for the report. Are you interested in fixing this? I suspect it'll be fairly trivial.
It looks like %a and %A don't work either (at a quick glance, looks like they should be equivalent to %x / %X). Not sure if that will be trivial or not.
I don't program in Go; I'd rather not work up a PR. Just reporting an inconsistency I tripped over while testing the portability of my Awk scripts.
@JohnEarnest That's fine, I'll get to it at some point. Thanks again for the report.
Thanks again for the report. The fix is merged into master now. That fix also adds support for %a and %A and fixes the behaviour of %o, %x, %X (they should have been unsigned).