GNU bug report logs - #23665
spaces in keys: doc, --debug in LC_ALL=C

Previous Next

Package: coreutils;

Reported by: Karl Berry <karl <at> freefriends.org>

Date: Tue, 31 May 2016 18:33:02 UTC

Severity: normal

Tags: fixed

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 23665 <at> debbugs.gnu.org, Karl Berry <karl <at> freefriends.org>
Subject: bug#23665: spaces in keys: doc, --debug in LC_ALL=C
Date: Tue, 31 May 2016 22:15:22 -0400
> On May 31, 2016, at 20:54, Pádraig Brady <P <at> draigBrady.com> wrote:
> 
> On 01/06/16 01:38, Assaf Gordon wrote:
>> 
>> 2. add a bit more verbose progress information to the 'sort-debug-warn.sh' test - just so it'll be easier to discuss to the changed messages.
>> 
>> 3. removes the 'maybe_space_aligned' and modifies the condition a bit.
> 
> 2 and 3 are good to push.

Thank you, pushed in:
 http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=d548f87595a193e21b170368bc8fc2ded4dadb73
 http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=6223bf94bfeac75fb4252095864a80545ba00a0d

====

Regarding documentation: how about the following?

'sort' without '-t' separates fields by whitespace (tab and space characters) and considers the whitespace characters to be part of the field's text. Use 'b' sorting option to skip leading spaces.

Example:

   $ cat  s.txt
   M A
   M  C
   M   D
   M  B

Without 'b' leading spaces affect sorting order of the second field:

   $ LC_ALL=C sort -k2 s.txt
   M   D
   M  B
   M  C
   M A

With 'b', leading spaces are skipped:

   $ LC_ALL=C sort -k2b s.txt
   M A
   M  B
   M  C
   M   D

For troubleshooting use 'sort --debug':

   $ LC_ALL=C ./src/sort --debug -k2 s.txt 
   sort: using simple byte comparison
   sort: leading blanks are significant in key 1; consider also specifying 'b'
   M   D
    ____
   _____
   M  B
    ___
   ____
   M  C
    ___
   ____
   M A
    __
   ___

=========

Should such an example go in the documentation, or in the new 'gotcha' page ?

I can shorten the example (e.g. with only two letter, such as 'printf "A\n B\n"'), but perhaps a slightly longer more verbose example would help understand the issue in a glance.
The fixed first field "M" is there to make it visually clear where the spaces are.

comments welcomed,
 - assaf









This bug report was last modified 6 years and 245 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.