Closed bsdimp closed 3 years ago
I'll note both gawk and mawk also honor the FS='' convention of BWK. Both treat -F '' and -v FS="" consistently.
you're correct, this inconsistency will need to be fixed.
https://github.com/onetrueawk/awk/pull/128 I believe addresses this. Though I'm unsure how to write a regression test for this in the fixed-bugs directory
thanks for the fix. both regression tests and the general tests are going to be overhauled, i made a note to add a test for the -F / -v FS consistency.
Thanks!
While the 1003-2008 standard says that FS='' is undefined, one true awk treats this like every character is its own $n variable. This is documented in awk(1):
The man page does not mention that the separator string must be non-null in its description of -F.
This means that
echo foo | awk -v FS='' '{ print $1; }'
will print 'f', howeverecho foo | awk -F '' '{ print $1;}'
will print a warning:awk: field separator FS is empty
.1003-2008 also states that -F sepstring and -v FS=sepstring are identical:
This suggests to me that the warning is invalid and it should be set to the empty string, given the behavior documented in the manual. This would be the most conservative interpretation of the standard, and would also give useful behavior. A patch looks to be relatively straight forward, but I thought I'd file an issue first to make sure there's consensus around this detail before producing it.