bug-coreutils
[Top][All Lists]
Advanced

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

Re: mistake in sort -k argument processing?


From: Andreas Schwab
Subject: Re: mistake in sort -k argument processing?
Date: Fri, 22 Dec 2006 17:55:18 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

Evan Hunt <address@hidden> writes:

>> POSIX specifies that that character position (if present) shall be
>> positive for the field start spec and non-negative for the field end spec
>> (with zero denoting the last character of the field).  Thus GNU sort is
>> behaving correctly.
>
> Ah, okay, thanks.
>
> Bit of a doc problem in "info sort", then:
>
> `-k POS1[,POS2]'
> `--key=POS1[,POS2]'
>      Specify a sort field that consists of the part of the line between
>      POS1 and POS2 (or the end of the line, if POS2 is omitted),
>      _inclusive_.  Fields and character positions are numbered starting
>      with 1.       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      ^^^^^^
>
> ...so I figured the 0 wasn't supposed to be allowed.

That does not contradict the use of 0 to describe the special case of the
_last_ character (which has a varying, non-zero position in every field).

> It seems to me that the principle of least surprise would mandate
> that .0 in a position spec should either be the equivalent of not
> setting a character offset, *or* that it should mean the "zeroth"
> character of the field (which would be an error)...

There is no such thing as a "zeroth" character in the position counting.
For the start field you cannot denote the last character, so using 0 does
not make sense.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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