Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-15 Thread Thomas Wolff
Eric Blake wrote: According to Damo, David on 1/14/2010 3:39 PM: Hi, I had a script that worked on UNIX, but on Cygwin it does not work. When I set a variable in a while loop I can't use it after the loop. However, this worked in UNIX. Any ideas why? Yes. ksh vs. bash.

Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-15 Thread Mark J. Reed
On Friday, January 15, 2010, Thomas Wolff wrote: As was responded before, this isn't supposed to work in a pipe. Not in ksh either, I think, No, it works in real ksh. If the last command in a pipeline is a builtin, it is run in the current shell. $ unset foo bar $ echo ${foo=hiya} | read

RE: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-15 Thread Brian Wilson
The pipe is what spawns the sub shell. In Unix the last process runs in your current shell. In Linux the first process of the pipe runs in the current shell. The difference is that when the while statement (which is run in the sub shell) finishes the sub shell dies and any variable changes

Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-15 Thread Eric Blake
Brian Wilson wilson at ds.net writes: The pipe is what spawns the sub shell. In Unix the last process runs in your current shell. In Linux the first process of the pipe runs in the current shell. The difference is that when the while statement (which is run in the sub shell) finishes

Can't set variables in a while loop that is passed to the rest of the script.

2010-01-14 Thread Damo, David
Hi, I had a script that worked on UNIX, but on Cygwin it does not work. When I set a variable in a while loop I can't use it after the loop. However, this worked in UNIX. Any ideas why? All variables set after the done command are blank, but can be seen in the while loop.

RE: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-14 Thread Damo, David
Hi, I have fixed the problem. It seems in cygwin it spawns a subshell even under bash. I used a for loop instead and everything worked nicely. for line in `sed 's/\$/^/g' $propfile` do nvpair=$(echo $line | awk -F= '{print $1,$2}') set -- $nvpair if [ ! $1 = ]; then

Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-14 Thread Jeremy Bopp
On 1/14/2010 5:23 PM, Damo, David wrote: Hi, I have fixed the problem. It seems in cygwin it spawns a subshell even under bash. I used a for loop instead and everything worked nicely. for line in `sed 's/\$/^/g' $propfile` do nvpair=$(echo $line | awk -F= '{print $1,$2}')

Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-14 Thread Matthias Andree
Am 15.01.2010, 00:40 Uhr, schrieb Jeremy Bopp jer...@bopp.net: On 1/14/2010 5:23 PM, Damo, David wrote: Hi, I have fixed the problem. It seems in cygwin it spawns a subshell even under bash. I used a for loop instead and everything worked nicely. for line in `sed 's/\$/^/g' $propfile` do

Re: Can't set variables in a while loop that is passed to the rest of the script.

2010-01-14 Thread Eric Blake
According to Damo, David on 1/14/2010 3:39 PM: Hi, I had a script that worked on UNIX, but on Cygwin it does not work. When I set a variable in a while loop I can't use it after the loop. However, this worked in UNIX. Any ideas why? Yes. ksh vs. bash.