2020-02-04 19:56:05 +0700, Robert Elz: [...] > What I am at the very least unclear about, is that the way that this > group chose to require "--" processing, appears to me to also require > that any arg (before that "--" or an arg not starting with "-") which > does start with "-" be treated as an option - which since we have no > options (not sure if any shell does, I haven't encountered any) would > *require* issuing an "invalid option" error. [...]
AFAICT, the behaviour of exec -a foo bar would be unspecified because -a is not an option of POSIX exec. So an implementation can choose to do what they please including what many shells do and treat it as an option that takes an argv[0] as parameter, or to treat that -a as an unknown option and report an error, or to consider it as the command to execute. Ideally, applications should ideally treat it as an option (and error out if it's not supported) for consistency, but some implementations may not want to, for instance for backward compatibility (but what will they do then when POSIX specifies exec -a?). See how some implementations of commands like true, false, printf don't error out for some arguments that start with "-" but are all required to support "--". true --help true x behaviour is unspecified But true true -- is. -- Stephane