[git commit] cut: fix handling of -d ''
Denys Vlasenko
vda.linux at googlemail.com
Fri Dec 13 18:31:41 UTC 2024
commit: https://git.busybox.net/busybox/commit/?id=96a230f17ba6cb1a7ad1e383d595424da02e87fc
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
coreutils/cut.c | 2 +-
testsuite/cut.tests | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/coreutils/cut.c b/coreutils/cut.c
index e12c56732..e33626d7f 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -309,7 +309,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
#endif
if (!odelim)
odelim = (opt & OPT_REGEX) ? " " : delim;
- if (!delim || !*delim)
+ if (!delim)
delim = (opt & OPT_REGEX) ? "[[:space:]]+" : "\t";
// argc -= optind;
diff --git a/testsuite/cut.tests b/testsuite/cut.tests
index 8da390cd7..52d05fde3 100755
--- a/testsuite/cut.tests
+++ b/testsuite/cut.tests
@@ -142,4 +142,16 @@ testing "cut -dNEWLINE --output-delimiter EMPTY_INPUT" \
"" \
"" ""
+# This seems to work as if delimiter is never found.
+# We test here that -d '' does *not* operate as if there was no -d
+# and delimiter has defaulted to TAB:
+testing "cut -d EMPTY" \
+ "cut -d '' -f2-" \
+ "1 2\t3 4 5\n" \
+ "" "1 2\t3 4 5\n"
+testing "cut -d EMPTY -s" \
+ "cut -d '' -f2- -s" \
+ "" \
+ "" "1 2\t3 4 5\n"
+
exit $FAILCOUNT
More information about the busybox-cvs
mailing list