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.

This question is somewhat similar to this: Unix/Linux command syntax

Suppose I have a program foo that takes arguments -a and -b. If both a and b take a string argument what is the meaning of this

foo -b -a bar

If multiple b:s are allowed

foo -b -a -b

??

Is there a true specification of the command line syntax somewhere?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Unless you can find something that says option arguments can't start with a minus sign, then the only possible interpretation is

-b=-a
bar

See also: POSIX Utility Conventions.

share|improve this answer
    
So I need to know if the option takes an argument or not, otherwise it will be impossible to know what it is. –  user877329 Sep 4 '12 at 15:01
    
Yes, that's my understanding. –  Mikel Sep 4 '12 at 15:41
1  
@user877329 See also the getopt function and the getopts utility. Most C programs use getopt (or a some extension of it that allows options to be more than one letter long, such as GNU getopt_long) and most shell scripts use getopts. –  Gilles Sep 4 '12 at 22:14

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.