GNU bug report logs - #26631
tr: add safe-quoting when reporting operand errors

Previous Next

Package: coreutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sun, 23 Apr 2017 23:40:02 UTC

Severity: wishlist

Full log


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

From: Pádraig Brady <P <at> draigBrady.com>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>,
 26631 <at> debbugs.gnu.org
Subject: Re: bug#26631: tr: extra operand ‘\\\\’
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




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

Previous Next


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