How does the POSIX shell grammar
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10
accept a simple command with assignment such as:
FOO=bar foobar
The first word here must be accepted as token ASSIGNMENT_WORD
by Rule 7b (although this rule is not specified explicitly to apply to the productions involving ASSIGNMENT_WORD
, but I guess that is understood).
Then there is no way to accept the second word. The only way to try to reduce it would be with cmd_word
production, but that requires Rule 7b to say this is a WORD
and Rule 7b does not say anything about words that do not contain =
.
One has to add to Rule 7b a statement such as:
If the TOKEN does not contain `=` then it is a `WORD`.
Without this, the grammar as written currently is faulty. Am I correct?
Best Answer
The grammar will only assign one word; successive words after that will be treated as a command.
Keep in mind that the rule you are citing refers to a
TOKEN
, and that cannot contain an unquoted space. See 2.3 Token Recognition, e.g.,