Bug 13361

Summary: awk NF corrupt when using FS regex and + (matching one or more of preceding expression)
Product: Busybox Reporter: Mavik <mavik>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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