What is the double dash in this bash script excerpt doing

前端 未结 3 1152
天涯浪人
天涯浪人 2021-01-07 03:26

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         


        
3条回答
  •  臣服心动
    2021-01-07 04:09

    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.

提交回复
热议问题