5 ms·
What do we call the "--" part in a command like this: git checkout HEAD -- <filename> I find it hard to remember things unless I understand their purpose.
by soupshield 4y ago
What do we call the "--" part in a command like this:
git checkout HEAD -- <filename>
I find it hard to remember things unless I understand their purpose. It looks like it's specifying an argument but without an argument name (e.g. --verbose), unless it's similar to a pipe | symbol and <filename> is being passed to the checkout command as some special kind of argument?
- swordbeta 4y agohttps://unix.stackexchange.com/a/11382 https://unix.stackexchange.com/a/11382
- ttymck 4y agoIt is a delimiter indicating the end of options: https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean https://unix.stackexchange.com/questions/11376/what-does-dou...
- gizmo686 4y agoI don't know what it is called, but it forces what comes after to be interpreted as a filepath. This is not git specific, but a common convention for CLI tools. Try running: > touch -- -i foo > rm -- -i foo And compare what happens without the "--".
- soupshield 4y agoThank you for this brilliant explanation (complete with interactive example :) I completely get it now.
- pojzon 4y agoNot only a filepath, this means pass anything past “—-“ ‘as is’ as an input and not an option flag. docker run -it nginx —- ls la
- drdec 4y agoNot a file path specifically and not an input exactly but I think the proper word would be an argument.
- soupshield 4y agoAh yes I've seen it in those kind of contexts too. Thanks everyone this has really clicked in to place for me :)
- CRConrad 4y agoObAgainstTheGuidelines: Me too.
- tremon 4y agoAnd then we have startx, which starts both an X server and the X client specified: startx /path/to/client --with --client-options and arguments -- --server-options -go --here Here, the double dash is used to separate the client options from the server options (the path to the server binary is compiled-in, IIRC).
- wruza 4y agoIt means “stop processing arguments as options and leave them alone” to getopt-likes. E.g. to rm file named “-f”: rm -- -f Idk the word, just minus minus.
- soupshield 4y ago> E.g. to rm file named “-f”: I've defintely had this sort of problem in the past :)
- vultour 4y agorm ./-f