diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-13 19:31:41 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-13 19:31:41 +0100 |
commit | 96a230f17ba6cb1a7ad1e383d595424da02e87fc (patch) | |
tree | e361a03c59c1bde0d72c9b857b4b49e34e13c9f1 | |
parent | 9adafbc1184a413999e7c8bbfc2de85bda3e0b97 (diff) | |
download | busybox-w32-96a230f17ba6cb1a7ad1e383d595424da02e87fc.tar.gz busybox-w32-96a230f17ba6cb1a7ad1e383d595424da02e87fc.tar.bz2 busybox-w32-96a230f17ba6cb1a7ad1e383d595424da02e87fc.zip |
cut: fix handling of -d ''
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/cut.c | 2 | ||||
-rwxr-xr-x | testsuite/cut.tests | 12 |
2 files changed, 13 insertions, 1 deletions
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) | |||
309 | #endif | 309 | #endif |
310 | if (!odelim) | 310 | if (!odelim) |
311 | odelim = (opt & OPT_REGEX) ? " " : delim; | 311 | odelim = (opt & OPT_REGEX) ? " " : delim; |
312 | if (!delim || !*delim) | 312 | if (!delim) |
313 | delim = (opt & OPT_REGEX) ? "[[:space:]]+" : "\t"; | 313 | delim = (opt & OPT_REGEX) ? "[[:space:]]+" : "\t"; |
314 | 314 | ||
315 | // argc -= optind; | 315 | // 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" \ | |||
142 | "" \ | 142 | "" \ |
143 | "" "" | 143 | "" "" |
144 | 144 | ||
145 | # This seems to work as if delimiter is never found. | ||
146 | # We test here that -d '' does *not* operate as if there was no -d | ||
147 | # and delimiter has defaulted to TAB: | ||
148 | testing "cut -d EMPTY" \ | ||
149 | "cut -d '' -f2-" \ | ||
150 | "1 2\t3 4 5\n" \ | ||
151 | "" "1 2\t3 4 5\n" | ||
152 | testing "cut -d EMPTY -s" \ | ||
153 | "cut -d '' -f2- -s" \ | ||
154 | "" \ | ||
155 | "" "1 2\t3 4 5\n" | ||
156 | |||
145 | exit $FAILCOUNT | 157 | exit $FAILCOUNT |