[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: discrepancy with variable assignments and simple commands between sh
From: |
Chet Ramey |
Subject: |
Re: discrepancy with variable assignments and simple commands between sh and bash |
Date: |
Wed, 25 Aug 2010 09:36:30 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 |
On 8/25/10 1:39 AM, Jan Schampera wrote:
> Okay, I think I found something
>
> [POSIX excerpts]
> - When a function is executed, it shall have the syntax-error and
> variable-assignment properties described for special built-in utilities in
> the enumerated list at the beginning of Special Built-In Utilities .
> - Variable assignments specified with special built-in utilities remain in
> effect after the built-in completes; this shall not be the case with a
> regular built-in or other utility.
>
> [Bash docs about POSIX mode]
> 24. Assignment statements preceding shell function calls persist in the
> shell environment after the function returns, as if a POSIX
> special builtin command had been executed.
>
> Conclusion (still waiting for the Austin Group undercover guy):
> - POSIX specifies this behaviour
> - Bash in Bash-mode overrides this (which results in intuitive behaviour,
> IMHO)
> - Bash in POSIX-mode respects it
Your conclusions are correct.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/