benhoyt / goawk

A POSIX-compliant AWK interpreter written in Go, with CSV support

Home Page:https://benhoyt.com/writings/goawk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for %i in format strings.

JohnEarnest opened this issue · comments

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.