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


Groups > gnu.bash.bug > #14287

Re: -- paramter does not work in bash 4.4

From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: -- paramter does not work in bash 4.4
Date 2018-07-02 16:41 -0500
Organization Red Hat, Inc.
Message-ID <mailman.2972.1530567699.1292.bug-bash@gnu.org> (permalink)
References <20180630130624.5194E26E27D0@mail.sorunome.de>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web