GNU bug report logs - #33113
ls: incorrect quoting of "="

Previous Next

Package: coreutils;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Sun, 21 Oct 2018 23:45:02 UTC

Severity: normal

Tags: confirmed

Full log


Message #11 received at 33113 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 33113 <at> debbugs.gnu.org
Subject: Re: bug#33113: incorrect and inconsistent quoting in ls output
Date: Mon, 22 Oct 2018 10:44:57 +0200
On 2018-10-22 01:21:40 -0700, Paul Eggert wrote:
> Vincent Lefevre wrote:
> > I get the following with ls (GNU coreutils) 8.30.
> > 
> > zira% touch a=b a=b\&c
> > zira% ls a=b*
> > 'a=b'  'a=b&c'
> > zira% ls -b a=b*
> > a=b  a=b&c
> > zira% ls -F a=b*
> > 'a=b'  'a=b&c'
> > zira% ls -bF a=b*
> > a\=b  a\=b&c
> > 
> > AFAIK, the = character is not a shell metacharacter (except with zsh
> > but only in the first position), thus does not need to be quoted.

Actually it seems that the meaning of "metacharacter" is ambiguous.
In bash, & is regarded as a metacharacter:

  metacharacter
      A  character that, when unquoted, separates words.  One of the
      following:
      |  & ; ( ) < > space tab newline

> '=' is a shell metacharacter after 'set -k' in Bash.

It's a special character, but not a metacharacter (see above).
But then I agree on the need for quoting, if particular shells
are taking into account.

> > Moreover, while & is not a metacharacter, it is a special character
> > that should be quoted for practical reasons.
> 
> As far as I can see '&' is being quoted correctly in the above examples.

Not with "ls -bF": the quoting in a\=b&c is inconsistent.
Just like =, & should be quoted. Or = shouldn't be quoted
(see below).

> -b means to quote for C strings, not for the shell.

Hmm, yes... The issue here is that -b was actually changing the
quoting style, hence my confusion on this point. That's a bug in
the ls man page, which does not say so:

       -b, --escape
              print C-style escapes for nongraphic characters

The info manual is OK:

‘-b’
‘--escape’
‘--quoting-style=escape’
     Quote nongraphic characters in file names using alphabetic and
     octal backslash sequences like those used in C.

> If you want to quote for the shell, try
> --quoting-style='shell-escape'.

That's already the default. Actually, the confusion comes from the
ls man page.

On the behavior, there's still the issue concerning = and &.

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




This bug report was last modified 6 years and 230 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.