Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: posix compliance



> A quick report from UseNIX: One thing Jordan Hubbard of Apple
mentioned was
> that our positional parameters ($1, $2, etc.) are assignable whereas
they
> are
> not in bash (Chet Ramey, who was also present, confirmed this). The
bash
> behavior is apparently what POSIX specifies.

It depends.

SUS V3 (which I hope is quite reliable representation of POSIX) says
that interpretation of

WORD1=WORD2

where WORD1 is not a name is implementation defined. It may be legally
interpreted as assignment.


You are correct that in case of ${WORD1=WORD2} it is prohibited:

${parameter:=word} 
Assign Default Values. If parameter is unset or null, the expansion of
word shall be assigned to parameter. In all cases, the final value of
parameter shall be substituted. Only variables, not positional
parameters or special parameters, can be assigned in this way.

In case of read built-in it is unclear. There are no explicit
restrictions; one may infer that special parameters are invalid only
from this line:

var 
The name of an existing or nonexisting shell variable.

and only due to usage of "name" here.


-andrej



Messages sorted by: Reverse Date, Date, Thread, Author