Re: 'ls' name and 'ls | grep name' different

From: φ__Dhénin_Jean-Jacques <dhenin_at_gmail.com>
Date: Sat, 09 Mar 2024 17:55:34 UTC
et voila ::; ls 1989*1989 Amnésia.mp4:; LANG=fr_FR.UTF-8:; ls 1989*1989
Amn??sia.mp4


Le sam. 9 mars 2024 à 17:41, Kyle Evans <kevans@freebsd.org> a écrit :
On 3/9/24 10:37, Michael Sierchio wrote:
> 
> 
> On Sat, Mar 9, 2024 at 11:19 AM φ Dhénin Jean-Jacques <dhenin@gmail.com  
> <mailto:dhenin@gmail.com>> wrote:
> 
>     Bonjour,
> 
>     I explain  it as simple as possible:
> 
>     :;  set | egrep 'LC_A|LANG'
>     GDM_LANG=fr_FR.UTF-8
>     LANG=fr_FR.UTF-8
>     LC_ALL=fr_FR.UTF-8
>     SLIM_LANG=fr_FR.UTF-8
> 
>     :;  ls -i  1989* ; ls -i | grep 1989 ;  ls -ib  1989* ; ls -ib |
>     grep 1989
>     9920 1989 Amn*??*sia.mp4
>       9920 1989 Amn*é*sia.mp4
>     9920 1989 Amn\303\251sia.mp4
>       9920 1989 Amn\303\251sia.mp4
> 
> 
> Bonjour J-J –
> 
> It's not that the pipe modifies the stream, it's that 'ls' has decided 
> that 'e-accent-aigu' is unprintable in the current locale.
> 
> Try ls -B and then investigate the locale.
> 
> *-B*       Force  printing    of  non-printable  characters  (as  defined by
>       /ctype/(3)  <
https://man.freebsd.org/cgi/man.cgi?query=ctype&sektion=3&a
propos=0&manpath=FreeBSD+14.0-RELEASE+and+Ports>        and current locale
settings) in file  names  as *\*/xxx/,
>              where/xxx/  is the       numeric value of the character in
octal.  This
>              option is not defined in IEEE Std 1003.1-2008 ("POSIX.1")
> 

ls(1) notably does toggle this behavior on by default only if stdout is 
a tty requiring the above noted flag, and leaves it disabled if it's piping:

https://cgit.freebsd.org/src/tree/bin/ls/ls.c#n241

This gives grep the chance to just let it render.

Thanks,

Kyle Evans


--
---------------------------------------------------------📞 06 89 66 51 35
(V)      Dhénin Jean-Jacques
( ..)     48, rue de la Justice 78300 Poissy
c(')(')  dhenin@gmail.com
---------------------------------------------------------