Hello, On Thu, 16 Mar 2017, Bernhard Voelker wrote: [..]
This is common to most-to-all command-line utilities using the library functions getopt(3)/getopt_long(3) to parse options ('man getopt_long').
In coreutils, this is documented in "common options":
https://www.gnu.org/software/coreutils/manual/html_node/Common-options.html#...
'--'
Delimit the option list. Later arguments, if any, are treated as operands even if they begin with '-'. For example, 'sort -- -r' reads from the file named -r. [..] I'm wondering why this isn't mentioned in grep's documentation
Because it is only relevant in the shell, where the '*' gets expanded. And that is documented there. If you have a file somewhere named '-i', and call e.g. 'rm *', the *SHELL* expands the '*' and thus rm gets called with the argument and in this case option '-i' somewhere in the call! E.g.: $ ls -1 -i a b $ bash -x -c 'rm -v * ' + rm -v -i a b #### note this is the line! rm: remove regular empty file `a'? n rm: remove regular empty file `b'? n $ csh -x -c 'rm -v * ' rm -v -i a b #### note this is the line! rm: remove regular empty file `a'? n rm: remove regular empty file `b'? n $ zsh -x -c 'rm -v * ' +zsh:1> rm -v -i a b #### note this is the line! rm: remove regular empty file `a'? n rm: remove regular empty file `b'? n And (t)csh is about as different from bourne/ksh/zsh as it gets. *Gah* Don't you learn the absolute basics of the shell you use anymore? Why in the world should rm act otherwise when you call it with the '-i' option? No matter if you typed the -i or if it is the result of globbing? Having '--' as a stop-gap to end options in getopt(3) is just convienience. And _any_ CLI tool taking options, whether using getopt(3) or something else will get called with e.g. '-i' and react on it, unless you use '--' where taken, or the './' prefix or a full path. To sum it up: this all belongs into the shell-documentation, where it is, and not into the documentation of every program taking options on the command line. HAND, -dnh -- River: "Also, I can kill you with my brain." --Episode #11, "Trash" -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org