ThomasDickey / original-mawk

bug-reports for mawk (originally on GoogleCode)
http://invisible-island.net/mawk/mawk.html
17 stars 2 forks source link

OFS doesn't act like a separator #75

Open Pyrrha opened 6 months ago

Pyrrha commented 6 months ago

Hello,

I'm using the awk command to increase a version number.

$ awk -vFS=. -vOFS=. '{$NF++;print}' <<< 1.2.99
1.2.100

However, when using the same command with mawk, I'm getting another behaviour.

$ mawk -vFS=. -vOFS=. '{$NF++;print}' <<< 1.2.99
1.2.99.

I think this is an issue with OFS, but maybe not only. Could also be the parsing, that doesn't catch the \n properly? What do you think?

Thanks

ThomasDickey commented 6 months ago

There's more than one difference that I see, depending on the options used. Since awk (bwk) and gawk are giving the same result, it's something to investigate.

With neither FS or OFS, and changing the print to make it more apparent

In the first example, I suppose that because the string does not look like a valid number, mawk ignores the increment. The second and third examples give the same result, so OFS appears irrelevant. Whether mawk should increment the last field -- that seems familiar (perhaps already reported difference). So I'll keep this open until I've had a chance to investigate those two differences.