eg.
git diff [options] [<commit>] [--] [<path>...]
What's the reason --
is used here? Is it to separate groups of positional parameters, namely commit
and path
's? Would this explanation be consistent with other commands' usage of --
?
eg.
git diff [options] [<commit>] [--] [<path>...]
What's the reason --
is used here? Is it to separate groups of positional parameters, namely commit
and path
's? Would this explanation be consistent with other commands' usage of --
?
The generalized use of this sigil is specified in POSIX Utility Syntax Guidelines:
Guideline 10: The first
--
argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.
Thus, paths that begin with -
can be specified without the need for a prefix such as ./
if --
is specified as a prior option in a tool compliant with the above guidelines.
While tools (such as git
) that are not specified by POSIX are not required to comply with the standard, doing so remains good form.