I\'m looking at an excerpt of bash and I\'m trying to understand what exactly is happening here, particularly in the COMPREPLY
assignment:
case
The meaning of --
really depends on the program you are executing. In this example compgen
. Check the documentation of this program, it should be explained there.
A common convention that is not necessarily always followed is to treat everything after --
as arguments, and do not try to parse as options or flags. As a concrete example, consider the case of running the GNU ls
command to get a detailed listing of a file named -t
. Running ls -l -t
will treat -t
as an option (order output by time), not as a filename argument. The solution is ls -l -- -t
, this way ls
will not try to parse the arguments after --
. This is just a convention and not all programs may follow it. Note also that I wrote GNU ls
not just ls
, because other implementations may behave differently.