← Commit list

96a230f17

Denys Vlasenko
Denys Vlasenko
2024-12-13
SUCCESS Duration: 156s

Subject

cut: fix handling of -d ''

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/cut.c+1 -1
@@ -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;
testsuite/cut.tests+12 -0
@@ -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