Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
pipe affects scope of globals?
- X-seq: zsh-workers 20950
- From: "Dwyer, William K" <bill.dwyer@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: pipe affects scope of globals?
- Date: Tue, 8 Mar 2005 13:18:13 -0500
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
hi,
i have a possible bug. maybe i deserve it for using globals ;) but i still
think this should not be the behaviour of scoping variables in the shell.
calling a function and piping it to read a variable seems to affect the
scope of its internal variables! huh? here is example code:
add_1_to_x_and_echo_2() {
(( x = x + 1 ))
echo 2
}
x=0
y=1
echo BEFORE
echo x=$x
echo y=$y
echo "call add_1_to_x_and_echo_2 and don't pipe to read"
add_1_to_x_and_echo_2
echo AFTER
echo x=$x
echo y=$y
echo "now call add_1_to_x_and_echo_2 and pipe to read"
add_1_to_x_and_echo_2 | read y
echo AFTER
echo x=$x
echo y=$y
echo "oooops! why didn't x change?"
=================================================================================================
.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author