Re: bash oddity

2001-01-20 Thread Hal Burgiss
On Sat, Jan 20, 2001 at 11:24:22AM -0800, John H Darrah wrote: > On Thu, 18 Jan 2001, Hal Burgiss wrote: > > num=0 > echo 1 > tmp > > while read line > do > num=1 > echo $num > done < tmp > > echo $num > > The above will accomplish the same thing by redirecting > stdin from "tmp" for t

Re: bash oddity

2001-01-20 Thread John H Darrah
On Thu, 18 Jan 2001, Hal Burgiss wrote: > > Is the below expected behavior? or bug? Values assigned to variables > within the loop, are not visible outside the loop. Using something > like 'while true' works as I would expect. > > > #!/bin/bash > ## script: testing > ## test variable visibilit

Re: variable scope in a loop (was : bash oddity)

2001-01-19 Thread Hal Burgiss
On Fri, Jan 19, 2001 at 12:45:11PM -0500, [EMAIL PROTECTED] wrote: > regarding why there is this odd feature about variable scope in > the bash shell, i suspect it's because it has the same feature as > the korn shell regarding variables and loops. > > in a normal loop in ksh, all variables

variable scope in a loop (was : bash oddity)

2001-01-19 Thread rpjday
sorry i can't include the previous text, i'm having to type this into a browser (ack!). regarding why there is this odd feature about variable scope in the bash shell, i suspect it's because it has the same feature as the korn shell regarding variables and loops. in a normal loop in ksh,

Re: bash oddity

2001-01-19 Thread Hal Burgiss
On Fri, Jan 19, 2001 at 10:36:47AM -0500, Jeff Lane wrote: > On Thu, 18 Jan 2001, Hal Burgiss wrote: > > [10:32:59][jlane@§î£èñßøß]$ ./foo.bar > 1 > > (I renamed it to foo.bar) Re: previous post. I forgot there were two echos in there. So this would confirm that there are actually two copies o

Re: bash oddity

2001-01-19 Thread Hal Burgiss
On Fri, Jan 19, 2001 at 10:36:47AM -0500, Jeff Lane wrote: > On Thu, 18 Jan 2001, Hal Burgiss wrote: > > > Is the below expected behavior? or bug? Values assigned to > > variables within the loop, are not visible outside the loop. Using > > something like 'while true' works as I would expect. > >

Re: bash oddity

2001-01-19 Thread Jeff Lane
On Thu, 18 Jan 2001, Hal Burgiss wrote: > > Is the below expected behavior? or bug? Values assigned to variables > within the loop, are not visible outside the loop. Using something > like 'while true' works as I would expect. > > > #!/bin/bash > ## script: testing > ## test variable visibilit

Re: bash oddity

2001-01-18 Thread Hal Burgiss
On Thu, Jan 18, 2001 at 08:03:56PM -0800, Thornton Prime wrote: > > I don't think shells have a concept between local and global scope. The > issue is that the pipe creates a subshell, which inherits the first shell > environment, but doesn't pass it back when it exits ... here's an example > ...

Re: bash oddity

2001-01-18 Thread Statux
That makes sense.. so I'm right about the scope to some degree :) > I don't think shells have a concept between local and global scope. The > issue is that the pipe creates a subshell, which inherits the first shell > environment, but doesn't pass it back when it exits ... here's an example __

Re: bash oddity

2001-01-18 Thread Thornton Prime
On Thu, 18 Jan 2001, Hal Burgiss wrote: > On Thu, Jan 18, 2001 at 10:34:30PM -0500, Statux wrote: > > This is correct behavior (from what I've known). The variables in the loop > > are defined as temporary variables.. they have scope limited to the loop. I don't think shells have a concept b

Re: bash oddity

2001-01-18 Thread Hal Burgiss
On Thu, Jan 18, 2001 at 10:34:30PM -0500, Statux wrote: > This is correct behavior (from what I've known). The variables in the loop > are defined as temporary variables.. they have scope limited to the loop. Not all loops: num=0 #cat tmp | while read line ; do while [ $num -eq 0 ]; do num=1

Re: bash oddity

2001-01-18 Thread Statux
This is correct behavior (from what I've known). The variables in the loop are defined as temporary variables.. they have scope limited to the loop. > Is the below expected behavior? or bug? Values assigned to variables > within the loop, are not visible outside the loop. Using something > like '

bash oddity

2001-01-18 Thread Hal Burgiss
Is the below expected behavior? or bug? Values assigned to variables within the loop, are not visible outside the loop. Using something like 'while true' works as I would expect. #!/bin/bash ## script: testing ## test variable visibility num=0 echo 1 > tmp cat tmp |while read line ; do nu