bug-bash
[Top][All Lists]
Advanced

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

Re: -- paramter does not work in bash 4.4


From: Eric Blake
Subject: Re: -- paramter does not work in bash 4.4
Date: Mon, 2 Jul 2018 16:41:31 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

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



reply via email to

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