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

To reply to this bug, email your comments to 26631 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#26631; Package coreutils. (Sun, 23 Apr 2017 23:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 23 Apr 2017 23:40:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-coreutils <at> gnu.org
Subject: tr: extra operand ‘\\\\’
Date: Mon, 24 Apr 2017 01:39:56 +0800
$ tr -s x -d '\\'
tr: extra operand ‘\\\\’
Try 'tr --help' for more information.

I only gave '\\'.




Information forwarded to bug-coreutils <at> gnu.org:
bug#26631; Package coreutils. (Mon, 24 Apr 2017 03:52:02 GMT) Full text and rfc822 format available.

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




Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 29 Oct 2018 03:10:02 GMT) Full text and rfc822 format available.

Changed bug title to 'tr: add safe-quoting when reporting operand errors' from 'tr: extra operand ‘\\\\’' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 29 Oct 2018 03:10:02 GMT) Full text and rfc822 format available.

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.