bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21416: "--" syntax for ignoring flags doesn't seem to work right wit


From: Bob Proulx
Subject: 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
User-agent: Mutt/1.5.23 (2014-03-12)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]