i'm finding that the `var=val cmd` syntax isnt working the same between `sh` and `bash` when the simple command is a function. this is bash-4.1_p7, but testing some older ones seems to behave the same. i'm not sure if this is "by design" or a bug ...
simple example:
$ cat test.sh
unset a
a=a
echo e1 a=$a
a=b env | grep ^a=
echo e2 a=$a
f() { echo a=$a; }
a=c f
echo e3 a=$a
when run with `bash`, i get:
e1 a=a
a=b
e2 a=a
a=c
e3 a=a
however, when i execute with `sh` (a symlink to bash), i get:
e1 a=a
a=b
e2 a=a
a=c
e3 a=c
the difference here being the value in variable "a" after function "f"
finishes executing. i was expecting the behavior of `bash`, not of `sh`. i
cant seem to find anything covering this in the man page except for perhaps
interpreting the meaning of some sections to mean this behavior is allowed.
but i certainly didnt locate anything that would imply behavior of this would
differ across bash and sh ...
-mike
signature.asc
Description: This is a digitally signed message part.
