I'm trying to dispel this uncertainty I have about the use of the double-dash (two hyphens, --) as an end of options delimiter(as opposed to a long option prefix). It's possible some confusion arose when someone read that long options are a GNU convention and long options begin with --. But this is just unrelated to the end of option delimiter.

The usage of Which is fully compliant with IEEE Std 1003.1, 2013 Utility Syntax Guideline 10:

The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.

So one can look at the rm manpages for OSX(or FreeBSD), AIX, Solaris and HPUX - the well known UNIX '03 registered Unices:

  • OSX, AIX and Solaris1 refer to the -- delimiter verbatim in man rm
  • HPUX doesn't discuss it in man rm but has other commands which allow the said delimiter(such as touch)

Is there a single UNIX 03 registered product which can't do rm -- -foo today? Is it Solaris... HPUX? Can they do it even though they don't document it? Can we generalize this to all commands on those platforms at this point?

1. The Solaris 11 manual says in a final note: If a - - and a - both appear on the same command line, the second is interpreted as a file. And there is a space in between the first two hyphens. Is it just the hyphen or anything that would start with the hyphen in this context which would be interpreted as a file?


From Solaris 10:

~ touch testfile
~ rm -- testfile
~ ls testfile
testfile: No such file or directory
~ touch testfile
~ rm -- -f testfile
-f: No such file or directory
~ ls testfile
testfile: No such file or directory
~ rm - - -f testfile
-: No such file or directory
-f: No such file or directory
testfile: No such file or directory

So to answer your question, in Solaris 10, if the second instance starts with a hyphen, it is treated as a file.

  • Ok so in that case it accepts -- -f testfile with -f as one of two operands. But - - -f testfile reacts differently - even differently from the behavior described in the note on Solaris 11. Thanks! – user44370 Jun 26 '14 at 5:26
  • No. In both cases whether the first argument is -- or - -, the -f is treated as a file name. – Warwick Jun 26 '14 at 5:32
  • Yes you are right. I just meant that there is the extra -: No such file or directory i.e. 3 operands after a single dash. – user44370 Jun 26 '14 at 5:39
  • Yes. That is correct :-) – Warwick Jun 26 '14 at 5:43
  • Thank you, I will eventually have to validate this for myself on the target platforms but Solaris is, as always, a milestone! – user44370 Sep 11 '14 at 1:46

Your Answer

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