aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-04 19:00:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-04 19:00:06 +0100
commit758c2bd58e0a23cdf19be8bd7c963074aff54b50 (patch)
treede24deba31f3116329a5d634e34185b0d32a6610
parentf4f6e5144b9af71dc687dc14dba4a6caf8c28361 (diff)
downloadbusybox-758c2bd58e0a23cdf19be8bd7c963074aff54b50.tar.gz
awk: add a test that $NF is empty
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xtestsuite/awk.tests11
1 files changed, 9 insertions, 2 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index 06a531d96..92c83d719 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -398,12 +398,19 @@ testing 'awk do not allow "str"++' \
'' \
'anything'
-#gawk compat: FS regex matches only non-empty separators:
-#with -*, the splitting is NOT f o o b a r, but foo bar:
+# gawk compat: FS regex matches only non-empty separators:
+# with -*, the splitting is NOT f o o b a r, but foo bar:
testing 'awk FS regex which can match empty string' \
"awk -F '-*' '{print \$1 \"-\" \$2 \"=\" \$3 \"*\" \$4}'" \
"foo-bar=*\n" \
'' \
'foo--bar'
+# last+1 field should be empty (had a bug where it wasn't)
+testing 'awk $NF is empty' \
+ "awk -F '=+' '{print \$NF}'" \
+ "\n" \
+ '' \
+ 'a=====123='
+
exit $FAILCOUNT