eza-community / eza

A modern alternative to ls
https://eza.rocks
MIT License
11.2k stars 197 forks source link

feat: Implement -N switch to remove single quotes from filenames with special characters #584

Open ivovegter opened 10 months ago

ivovegter commented 10 months ago

Several years ago, coreutils (ls) was controversially changed to enclose filenames that contain spaces (or other characters that would need to be escaped in input) in single quotes, by default. eza does the same.

The reasoning was to permit the output of ls to be used as piped input to other programs.

Unlike ls, however, eza does not implement the -N switch that removes those quotation marks, nor does it respect the QUOTING_STYLE=literal environment variable, which also makes ls list files without single quotes.

Please implement both the -N switch, and reading the QUOTING_STYLE environment variable, to determine whether or not to enclose filenames with special characters in single quotes in the output listing.

cafkafk commented 10 months ago

Currently there is --no-quotes or smth I believe

PThorpe92 commented 10 months ago

Yes we have --no-quotes, but I think it's reasonable to have an ENV VAR:

EZA_QUOTE_STYLE which can be maybe literal or shell to kind-of match LS? or we could always go with always auto or never because LS technically does offer everything to be quoted. so auto would be only if there are spaces in the file name, always and never are obvious.

ivovegter commented 10 months ago

Thanks. I somehow missed --no-quotes. That will solve my problem in the mean time. Getting it as close as possible to a drop-in replacement to ls would be good, though.

PThorpe92 commented 10 months ago

Just remember that we are waiting on #569 to get merged so currently the --icons flag might cause some misalignment when combined with --no-quotes.

Also, I looked into what LS supports and I dont believe we need to support so many quoting styles, but I went ahead and made a PR to support always, auto, never so you could simply set EZA_QUOTING_STYLE=never

or choose to pass it in the command line.