diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-14 13:58:49 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-14 13:58:49 +0100 |
| commit | b25ea3f156c6b5927b358f9b12b90f1852f30311 (patch) | |
| tree | cc2e7f2cb4f7b25468377db0c355e90340c0914c /coreutils | |
| parent | d48400d8fb266526059eb43b318cb95132f61fb3 (diff) | |
cut: fix -F n-m to match toybox
function old new delta
cut_main 1339 1391 +52
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/cut.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c index f4cf5401b..3abebe7ad 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -243,6 +243,16 @@ static void cut_file(FILE *file, const char *delim, const char *odelim, start = next; continue; } + /* -F N-M preserves intermediate delimiters: */ + //printf "1 2 3 4 5 6 7\n" | toybox cut -O: -F2,4-6,7 + //2:4 5 6:7 + if (opt_REGEX && dcount <= cut_list[cl_pos].endpos) + continue; +// NB: toybox does the above for -f too, but it's a compatibility bug: +//printf "1 2 3 4 5 6 7 8\n" | toybox cut -d' ' -O: -f2,4-6,7 +//2:4 5 6:7 // WRONG! +//printf "1 2 3 4 5 6 7 8\n" | cut -d' ' --output-delimiter=: -f2,4-6,7 +//2:4:5:6:7 // GNU coreutils 9.1 } #if ENABLE_FEATURE_CUT_REGEX if (end != start || !opt_REGEX) |
