OK, going forward, to fix the spec, would we be in agreement that the spec should guarantee this:
In: sh - <anything> Where <anything> can be any number argument starting with -, +, being "--", "-" or not. Those <anything> would be taken as operands (the first being the script name, the rest its arguments) sh <options> -- <anything> <options> being any combination of the options specified, <anything> being as above. Those <anything> would be taken as operands (whose interpretation depends on whether -c, -s are provided). For "-" to be treated as the first operand, it has to be preceded by a "--" end-of-option marker, or passed as "sh - -" Anything else is unspecified. In particular, sh -o - (or sh -o-) is unspecified, because "-" is not a valid option name (it doesn't matter whether some shells may choose to just ignore that "-" and/or treat it as disabling verbose and xtrace or report and error). sh -x - file is unspecified (behaviours vary in practice) same for sh -c - code (even if behaviours do not vary in practice in that instance). AFAICT, that would make the API usable (-- (and historical "sh -") can be relied upon), allow all current POSIX shell implementations, and not break "#! /bin/sh -" common usages. -- Stephane