3

The problem

I don't want to see filenames quoted when they contain spaces.

Example

On OSX I see this when running ls:

> ls -l total 0 drwxr-xr-x 2 mafro staff 68 Mar 16 09:02 'dir with spaces' drwxr-xr-x 2 mafro staff 68 Mar 16 09:02 dir_with_spaces 

On my Debian box it looks like this:

> ls -l total 8 drwxr-xr-x 2 mafro mafro 4096 Mar 16 09:02 dir with spaces drwxr-xr-x 2 mafro mafro 4096 Mar 16 09:02 dir_with_spaces 

My shell is zsh with prezto and a tiny amount of my own customisation. I (should) have exactly the same dotfiles on both boxes

Here's ls. It's the same on both systems:

> which ls ls: aliased to ls --group-directories-first --color=auto 
3
  • 2
    You'll get the quoting on newer Debian releases, too. See Why is 'ls' suddenly wrapping items with spaces in single quotes Commented Mar 16, 2016 at 14:32
  • @MarkPlotnick you should make this comment an answer! I've searched high and low for this and didn't find that link you sent :) THANKS Commented Mar 16, 2016 at 16:10
  • @MarkPlotnick Debian undid this change in the mailing list because the maintainers agreed with me (asker of the question you linked) that it was a bad idea. Commented Apr 10, 2016 at 1:51

2 Answers 2

4

This is a new feature of Coreutils ls.

From the info documentation:

‘-N’
‘--literal’
‘--quoting-style=literal’

Do not quote file names. However, with ‘ls’ nongraphic characters are still printed as question marks if the output is a terminal and you do not specify the ‘--show-control-chars’ option.

1

To disable this feature, add export QUOTING_STYLE=literal to your ~/.bashrc or, if you are using recent GNU coreutils with shells that don't support export var=value, use:

QUOTING_STYLE=literal export QUOTING_STYLE 

IMO, the recently added quoting styles are a good feature, but they should not have changed the default behaviour because It breaks too many existing scripts and command line habits - especially for people who are doing the Right Thing and properly quoting their variables.

BTW, Debian reverted the behaviour in coreutils 8.25-2, so it was only present briefly in sid in 8.25-1.

3
  • It's still present in Arch Linux, however. Commented Mar 17, 2016 at 9:55
  • @ams I feel bad for you. Commented Apr 10, 2016 at 1:52
  • Upvoting but I thought I'd point out that the new(ish) output-style is only used when stdout is a terminal so it shouldn't break any scripts – and parsing ls was never a good idea: see unix.stackexchange.com/a/128987/22812 and mywiki.wooledge.org/ParsingLs Commented Nov 9, 2018 at 15:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.