Subject: Re: bug#23191: ls alignment bug

From: Pádraig Brady <[email-masked]>
Date: Wed, 16 Nov 2016 00:28:07 +0000

unarchive 23191
tag 23191 notabug
close 23191
stop

On 02/04/16 04:01, Seth Kushniryk wrote:
> I forgot to mention that this is coreutils 8.21 in Slackware
> 
> On 01-Apr-16 19:53, Seth Kushniryk wrote:
>> Hi, I've been having a minor issue with ls. It seems that sometimes the
>> character 'é' (e accent aigu) causes the rest of the listing to be
>> misaligned. My options are "-F -T 0".
>>
>> Here is an example of me using it in my music library:
>>
>> First Aid Kit/              Pink Floyd/                The Who/
>> Fleetwood Mac/              Queen/                     Ton Koopman/
>> Foreigner/                  Rage Against The Machine/  Trooper/
>> Frank Sinatra/              Red Rider/                 U2/
>> Félix Leclerc/             Rodriguez/                 Van Morrison/
>> George Harrison/            Roy Orbison/               Whitesnake/
>> Green Day/                  Run-DMC/                   Woody Guthrie/
>> Iron Butterfly/             Rush/
>> James/                      Simon and Garfunkel/
>>
>> Renaming the directory to "Felix Leclerc" fixes the issue. I think the
>> problem is in "ls.c" in the function "quote_name", and what it sets for
>> "size_t *width".

I think the problem is your locale settings.
It looks like the file is on disk in UTF-8 (where é takes 2 bytes),
while ls(1) is running in a single byte locale such as en_US.
In that mode those bytes are interpreted by ls(1) as separate
printable characters, resulting in the misalignment.
The -T0 uses spaces rather than tabs for alignment making
the issue more likely to hit.

The fix would be to set your locale to en_US.utf8 or equivalent.

thanks,
Pádraig