On 06/30/2018 08:06 AM, bashrep...@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

Reply via email to