coreutils
[Top][All Lists]
Advanced

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

Re: Does sort handle -t / correctly


From: Eric Blake
Subject: Re: Does sort handle -t / correctly
Date: Fri, 17 Apr 2015 13:09:57 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 04/17/2015 01:05 PM, Peng Yu wrote:

>>> If I don't know the number of fields, but I want to sort according to
>>> all fields (from 1 to whatever the max number of fields), is there a
>>> way to do it?
>>
>> No one has really asked for that before.  Are you going to propose some
>> possible extension syntax to make it obvious how to generate as many key
>> specifications as necessary to fully cover an arbitrary number of fields
>> in a line?
> 
> Since no -k options means treat each line just a whole string, maybe
> one can allow -k without specifying any columns as treating each line
> as all the set of fields in that line?

Sadly, it is not backwards-compatible to convert an option with
mandatory argument into an option with optional argument.  By your
proposal, 'sort -k1' would be unambiguous, but 'sort -k 1' would be
ambiguous as to whether it is 'use field 1 to the end of the line as the
only sort key, with stdin as input' (existing meaning) or 'sort by an
infinite number of keys, one per field, with ./1 as input' (new
meaning).  You'd have to burn a new option, maybe spelled -K, to get new
semantics.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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