uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.74k stars 1.27k forks source link

ls: unquoted names should be indented with a space if there is a quoted name #5632

Closed cakebaker closed 10 months ago

cakebaker commented 11 months ago

GNU ls indents unquoted names with a space if there is a quoted name:

$ touch a 'sp ace'
$ ls a 'sp ace' 
 a  'sp ace'
$ ls -l a 'sp ace' 
-rw-r--r-- 1 dho dho 0 Dec 10 16:38  a
-rw-r--r-- 1 dho dho 0 Dec 10 16:38 'sp ace'

uutils ls doesn't do such an indentation:

$ touch a 'sp ace'
$ cargo run ls a 'sp ace' 
a  'sp ace'
$ cargo run ls -l a 'sp ace' 
-rw-r--r-- 1 dho dho 0 Dec 10 16:38 a
-rw-r--r-- 1 dho dho 0 Dec 10 16:38 'sp ace'
allaboutevemirolive commented 11 months ago

Quoting flag for shell also didn't work.

$ ./coreutils ls --quoting-style=literal a 'sp ace'
a  sp ace

$ ./coreutils ls --quoting-style=shell a 'sp ace'
a  'sp ace'
$ ls --quoting-style=literal a 'sp ace'
a  sp ace

$ ls --quoting-style=shell a 'sp ace'
 a  'sp ace'
mtimaN commented 10 months ago

I wrote some code which patches this inconsistency but I am unsure how to write unit tests for it considering that ls formats differently if the output is directed to stdout.