Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14287 > unrolled thread

Re: -- paramter does not work in bash 4.4

Started byEric Blake <eblake@redhat.com>
First post2018-07-02 16:41 -0500
Last post2018-07-02 16:41 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: -- paramter does not work in bash 4.4 Eric Blake <eblake@redhat.com> - 2018-07-02 16:41 -0500

#14287 — Re: -- paramter does not work in bash 4.4

FromEric Blake <eblake@redhat.com>
Date2018-07-02 16:41 -0500
SubjectRe: -- paramter does not work in bash 4.4
Message-ID<mailman.2972.1530567699.1292.bug-bash@gnu.org>
On 06/30/2018 08:06 AM, bashreport@oninoni.de wrote:

> Description:
> 	[Detailed description of the problem, suggestion, or complaint.]
> 

That wasn't very detailed, so we have no idea how to reproduce what you 
are complaining about to know if it is an actual bash bug, or more 
likely a misunderstanding on your part how things work.

Note that POSIX has a special meaning for -- that most apps obey, where 
it means "end of options" and is silently removed, allowing all 
subsequent arguments on the command line to be taken as literal 
arguments even if they otherwise resemble options.  So, if you expect 
that an argument might start with -, then using the -- separator is common:

$ for arg in '' 1 - --; do printf .%s.\\n "$arg" | grep "$arg"; done
..
.1.
.-.
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
$ for arg in '' 1 - --; do printf -- .%s.\\n "$arg" | grep -- "$arg"; done
..
.1.
.-.
.--.


Meanwhile, there are a few exceptions, like 'echo', that are 
specifically required to behave differently from that normal behavior:

$ echo --
--

Note that POSIX even requires -- to work on applications that don't seem 
to take any options (at least, no options specified by POSIX); this is 
because POSIX allows for extensions:

$ dirname
dirname: missing operand
Try 'dirname --help' for more information.
$ dirname --
dirname: missing operand
Try 'dirname --help' for more information.
$ dirname -- --
.

So, with that said, do you have an example command line that you are 
still confused about, rather than a vague non-report?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web