Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Recently I got to know of -- that is double-hyphen which is used to tell a command that the option list has ended and what follows should not be considered as a option. So,

grep --  'search_word' *

would search for the given search_word. But you could see a unexpected behavior if you remove -- and if there is a single file that start with -, which would switch on the option that match with the chars in filename.

What is this -- called ? Is there any technical term to this ?

share|improve this question
3  
See the debate on Why do unix-heads say “minus”? then double it. –  manatwork Nov 22 '12 at 14:25
    
@manatwork No, square it! Should we say “minus dash” or “dash minus”? –  Gilles Nov 22 '12 at 23:12
    
I just pronounce it "--". –  dubiousjim Jan 11 '13 at 13:40
    
I encounter regularity the cd -- and cd - phenomena. while cd -- means essentially just cd and thus change into your $HOME, cd - means put your self into previous directory. This becomes handy when you wanted to cd .. but as with german keyboard layout I mix it often up with cd --. cd - will then put you back. :D –  math Sep 24 '13 at 7:33
add comment

2 Answers 2

up vote 14 down vote accepted

The -- is working for tools which use getopt(3) to process command line arguments and many API that parse POSIX style options.

From the manual page of getopt(3):

The interpretation of options in the argument list may be cancelled by the option `--' (double dash) which causes getopt() to signal the end of argument processing and return -1.

I would then say it is called double dash

share|improve this answer
    
But I'd bet there's some linguistic term for that. –  Rob Nov 22 '12 at 14:12
3  
getopt is not the only API that supports "--". Most APIs that parse POSIX style options in most languages support it. All POSIX utilities but echo and [ support it –  Stéphane Chazelas Nov 22 '12 at 14:30
    
@StephaneChazelas Thanks I edited the answer –  Matteo Nov 22 '12 at 14:50
add comment

The only two names which I've head in practise are "double dash" for referring to it aesthetically, and "end of options" for referring to it functionally.

share|improve this answer
    
i've seen it refered to as 'last-option' as well. –  Tim Kennedy Jan 11 '13 at 14:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.