[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33113: incorrect and inconsistent quoting in ls output
From: |
Vincent Lefevre |
Subject: |
bug#33113: incorrect and inconsistent quoting in ls output |
Date: |
Mon, 22 Oct 2018 10:44:57 +0200 |
User-agent: |
Mutt/1.10.1+136 (420226ce) vl-108074 (2018-10-17) |
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 <address@hidden> - 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)
- bug#33113: incorrect and inconsistent quoting in ls output, Vincent Lefevre, 2018/10/21
- bug#33113: incorrect and inconsistent quoting in ls output, Paul Eggert, 2018/10/22
- bug#33113: incorrect and inconsistent quoting in ls output,
Vincent Lefevre <=
- bug#33113: incorrect and inconsistent quoting in ls output, Paul Eggert, 2018/10/23
- bug#33113: incorrect and inconsistent quoting in ls output, Pádraig Brady, 2018/10/27
- bug#33113: incorrect and inconsistent quoting in ls output, Vincent Lefevre, 2018/10/28
- bug#33113: incorrect and inconsistent quoting in ls output, Paul Eggert, 2018/10/28
- bug#33113: incorrect and inconsistent quoting in ls output, Assaf Gordon, 2018/10/28