Hi!

I have this weird behavior that I do not understand: when running

        FOO=1 foo

I do not expect FOO to remain in the env after foo was invoked, even
if foo is a shell function.  However it does, _if_ bash is invoked
in POSIX mode, something which I couldn't find documented in the
model (and I wouldn't know where to find this information in POSIX).

Is this really on purpose?  It breaks natural assumptions in /bin/sh
scripting programming :/

$ cat /tmp/foo.sh
foo()
{
  echo "FOO=$FOO"
}

foo
FOO=1 echo "FOO=$FOO"
foo
FOO=1 foo
foo
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.
$ bash foo.sh
FOO=
FOO=
FOO=
FOO=1
FOO=
$ bash --posix foo.sh
FOO=
FOO=
FOO=
FOO=1
FOO=1    <======= unexpected



Reply via email to