cut: fix handling of -d ''
No binary (build failed)
—
(log yok)
| @@ -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; | |
| @@ -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 | |