[Top][All Lists]

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

Re: coreutils feature requests?

From: Eric Blake
Subject: Re: coreutils feature requests?
Date: Wed, 19 Jul 2017 09:15:43 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/19/2017 08:29 AM, Nellis, Kenneth wrote:
> From: Steeve McCauley
>> I can't believe I'd never thought of reordering output columns like this.  
>> FWIW, I agree that another option should be used to prevent issues with 
>> backward compatibility.
>> $ echo 1,2,3,4,5,6 | cut -d, -f3,5,2
>> 2,3,5
>> $ echo 1,2,3,4,5,6 | cut -d, -f3,5,2 -o
>> 3,5,2

Unfortunately, it takes time to add an option, and then for that
addition to percolate into the pre-built binaries of all the distros
that you use.  In the meantime, you can already use awk to get the
behavior you want today.  And since awk is already portable and required
by POSIX to be able to reorder output fields, it's that much more of a
burden to justify adding a feature to cut (adding a feature is easy if
it is easy to show that no other existing tools can fill the gap, but a
one-line awk program doesn't feel like no other tools being able to fill
the gap).  Adding a new feature to GNU Coreutils is also easier to do if
you can find someone else (like BSD) that already has the feature - but
to my knowledge, no common 'cut -o' exists in other major distributions.

> In addition, so that scripts can work across platforms, I (strongly) 
> recommend 
> that a cut-specific environment variable be defined to allow specifying the
> field ordering behavior. In that way my QNX 4 script (whose cut would balk at
> the -o option) would work with Gnu. One possibility:

Absolutely not.  We have already learned from experience that
environment variables that modify core program functionality, especially
NEW environment variables that are not already accounted for in old
scripts, tend to break old scripts.  If you want a different default,
our recommended approach is to write a shell script wrapper installed
earlier on your $PATH, rather than abusing environment variables for

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization: |

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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