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?


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


See also: POSIX Utility Conventions.

  • 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 'SO- stop being evil' Sep 4 '12 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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