On 08/24/2011 09:24 AM, Sam Steingold wrote:
CYGWIN_NT-5.2-WOW64 sds 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
BASH_VERSION='4.1.10(4)-release'

at the bash prompt I observe this:
$ f(){ echo a=$a b=$b c=$c ; }
$ unset a b c
$ a=a b=b f
a=a b=b c=
$ f
a= b= c=
which I believe is correct (i.e., variables set in "a=a b=b f" are unset
after f terminates).

This is bash's default behavior, but it violates POSIX.


alas, when I call /bin/sh on the same machine, I see this:

That tells bash to strictly obey POSIX, so you get the POSIX behavior.


f(){ echo a=$a b=$b c=$c ; }
f
a= b= c=
a=a b=b f
a=a b=b c=
f
a=a b=b c=

Which is indeed correct under the rules for POSIX (basically, POSIX requires function calls to behave like special built-ins, such that changes to the environment persist after the function call - the bash developer thinks the posix rule is counterintuitive, which is why the default bash behavior is opposite the posix behavior).

Your question is not cygwin-specific.

is this the expected behavior?

Yes.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to