Bug 13361 - awk NF corrupt when using FS regex and + (matching one or more of preceding expression)
Summary: awk NF corrupt when using FS regex and + (matching one or more of preceding e...
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-04 15:12 UTC by Mavik
Modified: 2020-12-04 17:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mavik 2020-12-04 15:12:18 UTC
I think that in all the following cases the value of `$NF` should be the empty string as is output by gawk (see below).

{{{
# printf "a==123=" | awk -F '=+' '{print $NF}'
=
# printf "a===123=" | awk -F '=+' '{print $NF}'
3=
# printf "a====123=" | awk -F '=+' '{print $NF}'
23=
# printf "a=====123=" | awk -F '=+' '{print $NF}'
123=
}}}

This is the output from gawk:

{{{
$ printf "a==123=" | awk -F '=+' '{print $NF}'

$ printf "a===123=" | awk -F '=+' '{print $NF}'

$ printf "a====123=" | awk -F '=+' '{print $NF}'

$ printf "a=====123=" | awk -F '=+' '{print $NF}'

}}}
Comment 1 Denys Vlasenko 2020-12-04 17:52:55 UTC
Fixed in git:

commit 5323af7f51808d5ff35c624ba70bdae4807f3717
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Mon Nov 16 10:40:32 2020 +0100

    awk: fix dodgy multi-char separators splitting logic