coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] cut: Optionally treat multiple consecutive delimiters as


From: Rob Landley
Subject: Re: [PATCH 4/4] cut: Optionally treat multiple consecutive delimiters as one
Date: Tue, 1 Aug 2023 11:27:49 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0

On 8/1/23 04:07, Dragan Simic wrote:
> Add new command-line option and the required logic that allow multiple
> consecutive delimiters to be treated as a single delimiter.  Of course,
> this option is valid only with the cut's field mode.
> 
> This new feature should make cut much more usable in various real-world
> applications, some of which are already mentioned in the gotchas.  For
> example, merging the consecutive delimiters is very useful when cut is
> used to process the outputs of various commands.

A year and a half ago I submitted cut -D -F -O to this list, which included a
regex mode for delimiters that would allow you to do that in a generic way:

  -F like -f but the -d delimiter is interpreted as an extended regex string
  -D disables field sort/collate so -f 3,2,1-3 prints fields 3 2 1 2 3
  -O specifies the output separator (default ' ' for -F, input delim for -f).

The -d default value also changes, the toybox code for which is:

  if (!TT.d) TT.d = FLAG(F) ? "[[:space:]][[:space:]]*" : "\t";

I.E. run of whitespace for -F, same old \t for -f. (There should be no change to
any existing behavior unless you specify one or more of the new options.)

These options have been in toybox since 2017 (commit 3eb69d412e79, I think it
missed the Android 8.1 cutoff and wound up in 9? Um, "Oreo" and "Pie"
respectively.) They were merged into busybox in 2021 (commit 0068ce2fa0e3).

The coreutils developers showed interest in merging support, came up with a
patch, and discussed it (defining --longopts for everything because gnu, which I
added to toybox in commit 9b108ab90b63), but the discussion petered out here:

  https://lists.gnu.org/archive/html/coreutils/2022-01/msg00050.html

When I asked again after the next release, they said it would be in 9.2:

  https://lists.gnu.org/archive/html/coreutils/2022-04/msg00010.html

In February of this year I asked again, and it was on the review list for the
upcoming release:

  https://lists.gnu.org/archive/html/coreutils/2023-02/msg00012.html

The coreutils 9.3 page on the web doesn't include the -DFO options:

  https://www.gnu.org/software/coreutils/manual/coreutils.html#cut-invocation

Which means I still need to use "awk '{print $3}'" instead of "cut -DF 3" in
scripts I want to run on the host.

Rob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]