On Sat, May 19, 2007 at 12:05:39AM +0200, Kevin F. Quinn wrote:
> 
> This was discussed in some detail on the bash mailing list:
> 
> http://www.mail-archive.com/bug-bash%40gnu.org/msg02622.html
> 
> Notably ksh, and the Solaris xpg4 sh, which both claim Posix
> compliance, behave the way bash does with regards this issue.

Well the Solaris xpg4 shell was ksh last time I checked :)
Also bash derives heavily from the Korn shell.  So in the
past I have not taken their collective behaviour as a
litmus test for POSIX compliance.

After all, POSIX isn't simply about the Korn shell.

> Chet Ramey explains in that thread how he reaches the conclusion that
> the Posix (well SUS) specifies that behaviour (I won't paraphrase to
> avoid mis-representation) - in particular here:
> 
> http://www.mail-archive.com/bug-bash%40gnu.org/msg02627.html

I can see how this paragraph can be construed to have this meaning.

        4. Each variable assignment shall be expanded for tilde
           expansion, parameter expansion, command substitution,
           arithmetic expansion, and quote removal prior to assigning
           the value.

However, it can also be read as simply saying that parameter expansion
must occur before the variables are assigned, and nothing more.

Normally if there is an intention to specify such a requirement and
it had to be done in an ambiguous way like this, there would be a
clarification in the rationale.  In this case there isn't any.

Of course we can't predict what a future revision might say, but
right now I do not agree that there is a requirement for this behaviour,
which I might add goes against all BSD-derived Bourne shells whose
behaviour were certainly given consideration in POSIX.

> > $ bash -c 'x=${K:=dvb0.net0} A=${K#dvb} echo $A'
> > 
> > $
> > 
> > As you can see, whether the first assignment affects a second
> > assignment is qutie haphazard within bash.
> 
> With respect to the third example, SUS is quite clear, I think.
> http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
> explicitly saves the 'variable assignments' until after 'expansion',
> where expansion is explicitly stated not to occur in variable
> assignments.

Could you quote the specific passage that states this?
 
> What do the compliance tests show for dash in this area?  I mention it
> as passing the compliance tests is worthwhile regardless how ambiguous
> the specification may be, and Chet mentioned it as an argument for the
> behaviour of bash.

I couldn't find a test for this in VSC Lite.  If you're aware a
relevant test, please let me know.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to