Re:Git In Two Minutes (updated after 8 years)
by soupshield on Saturday August 06, 2022 @04:42PM
(#32371419)
What do we call the "--" part in a command like this:
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?
[ Parent
| on HN ]
Re:Git In Two Minutes (updated after 8 years)
by ttymck on Saturday August 06, 2022 @04:48PM
(#32371471)
It is a delimiter indicating the end of options:
https://unix.stackexchange.com/questions/11376/what-does-dou...
Re:Git In Two Minutes (updated after 8 years)
by gizmo686 on Saturday August 06, 2022 @04:50PM
(#32371487)
I 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 "--".
Re:Git In Two Minutes (updated after 8 years)
by tremon on Saturday August 06, 2022 @05:06PM
(#32371593)
And 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).
Re:Git In Two Minutes (updated after 8 years)
by pojzon on Saturday August 06, 2022 @04:59PM
(#32371541)
Not only a filepath, this means pass anything past “—-“ ‘as is’ as an input and not an option flag.
docker run -it nginx —- ls la
Re:Git In Two Minutes (updated after 8 years)
by soupshield on Saturday August 06, 2022 @05:00PM
(#32371551)
Ah yes I've seen it in those kind of contexts too. Thanks everyone this has really clicked in to place for me :)
Re:Git In Two Minutes (updated after 8 years)
by CRConrad on Thursday August 11, 2022 @02:47AM
(#32422335)
ObAgainstTheGuidelines: Me too.
Re:Git In Two Minutes (updated after 8 years)
by drdec on Saturday August 06, 2022 @06:19PM
(#32372106)
Not a file path specifically and not an input exactly but I think the proper word would be an argument.
Re:Git In Two Minutes (updated after 8 years)
by soupshield on Saturday August 06, 2022 @04:57PM
(#32371530)
Thank you for this brilliant explanation (complete with interactive example :) I completely get it now.
Re:Git In Two Minutes (updated after 8 years)
by wruza on Saturday August 06, 2022 @04:54PM
(#32371505)
It 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.
Re:Git In Two Minutes (updated after 8 years)
by soupshield on Saturday August 06, 2022 @04:59PM
(#32371542)
> E.g. to rm file named “-f”:
I've defintely had this sort of problem in the past :)
Re:Git In Two Minutes (updated after 8 years)
by vultour on Saturday August 06, 2022 @05:12PM
(#32371628)
rm ./-f