GNU bug report logs - #21416
"--" syntax for ignoring flags doesn't seem to work right with GNU /bin/echo

Previous Next

Package: coreutils;

Reported by: "Robert \"Finny\" Merrill" <rfm <at> arista.com>

Date: Fri, 4 Sep 2015 19:11:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


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

From: Bob Proulx <bob <at> proulx.com>
To: "Robert \"Finny\" Merrill" <rfm <at> arista.com>
Cc: 21416 <at> debbugs.gnu.org
Subject: Re: bug#21416: "--" syntax for ignoring flags doesn't seem to work
 right with GNU /bin/echo
Date: Fri, 4 Sep 2015 19:22:04 -0600
Robert "Finny" Merrill wrote:
> ~/workspaces/diags-dev/s1 @bs360.sjc> /bin/echo --help
> Usage: /bin/echo [SHORT-OPTION]... [STRING]...
>   or:  /bin/echo LONG-OPTION
> Echo the STRING(s) to standard output.
> *snip*
> ~/workspaces/diags-dev/s1 @bs360.sjc> /bin/echo -- --help
> -- --help
> ~/workspaces/diags-dev/s1 @bs360.sjc>

Under what actual live conditions in the wild would someone be using
/bin/echo in this manor?

Most shell interpreters used for scripts will have a shell builtin
version of echo.

  $ ls -log /bin/sh
  lrwxrwxrwx 1 4 Nov  8  2014 /bin/sh -> dash
  $ /bin/sh -c 'echo --help'
  --help
  $ /bin/bash -c 'echo --help'
  --help
  $ /bin/ash -c 'echo --help'
  --help
  $ /bin/dash -c 'echo --help'
  --help
  $ /bin/ksh -c 'echo --help'
  --help
  $ /bin/csh -c 'echo --help'
  --help

I think this might be a problem that is purely academic as it can't
ever actually be hit in real life.  However if you provide an actual
example that would go a long way to making this problem clear.

> There doesn't seem to be a way to get /bin/echo to output the string "--help"

Woe is me for suggesting using -e or -E as they are terribly
non-portable options.  Don't use them!  Use printf instead.  But
having said that...

  $ /bin/echo -e --help
  --help
  $ /bin/echo -E --help
  --help

But please don't do it.  Use printf instead.  The shell printf command
has a standard syntax and may portably be used.

Bob




This bug report was last modified 9 years and 265 days ago.

Previous Next


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