Subject: Re: bug#26631: tr: extra operand ‘\\\\’

From: Pádraig Brady <[email-masked]>
Date: Sun, 23 Apr 2017 20:51:38 -0700

On 23/04/17 10:39, 積丹尼 Dan Jacobson wrote:
> $ tr -s x -d '\\'
> tr: extra operand ‘\\\\’
> Try 'tr --help' for more information.
> 
> I only gave '\\'.

That's a result of the quoting used,
the default mode add backslashes for some characters (including backslash).
Now you could argue that input params specified on the shell
should use shell quoting when being diagnosed.
If you change all those, then you're left with very few cases of quote(),
which suggests we should just switch to quotef() everywhere?
Using quotef() gives the following (note curly quotes are also not used):

  tr: extra operand '\\'

Note there are edge cases where shell quoting may be worse.
For example if you were trying to delete quotes, then:

  $ tr-before -s x -d "\"'"
  tr: extra operand ‘"'’

  $ tr-after -s x -d "\"'"
  tr: extra operand '"'\'''

Well maybe that's no worse, since neither diagnostic matches the input,
and I suppose the shell quoting has a better chance of matching the input
seeing as that's specified to a shell.

I'm leaning towards making that change.
I also remember Eric tentatively suggesting the same.

cheers,
Pádraig