Re: Fascinating problem with bash

2010-08-28 Thread Bob Proulx
Bob McGowan wrote: > All this got me to wondering, so I looked at the two links Bob provided. > And, I did some tests of my own. > > First, I think there's an error on the SubShell page, in the "example" > of the difference between a "subshell" and a full "child process", at > the end. The autho

Re: Fascinating problem with bash

2010-08-24 Thread Bob McGowan
On 08/24/2010 04:09 AM, Oliver Schneider wrote: > Hello Cameron, Bob, > >> As soon as I read this paragraph I saw the problem. I confirmed it >> looking at the code. It's a common problem. >> >> This construct: >> >> some_cmd | while read var ; do >> OTHER_VAR=... >> done >> >> will result in

Re: Fascinating problem with bash

2010-08-24 Thread Mike Bird
On Tue August 24 2010 04:09:39 Oliver Schneider wrote: > Okay, that is surprising indeed, as SHLVL is not being adjusted to reflect > that fact, according to my findings. But thanks a bunch for pointing that > out. It's surely more elegant to use this method than to write to a > temporary file. Yo

Re: Fascinating problem with bash

2010-08-24 Thread Oliver Schneider
Hello Cameron, Bob, > As soon as I read this paragraph I saw the problem. I confirmed it > looking at the code. It's a common problem. > > This construct: > > some_cmd | while read var ; do > OTHER_VAR=... > done > > will result in OTHER_VAR being unset at the completion of the loop. That >

Re: Fascinating problem with bash

2010-08-23 Thread Bob Proulx
Cameron Hutchison wrote: > This construct: > > some_cmd | while read var ; do > OTHER_VAR=... > done > > will result in OTHER_VAR being unset at the completion of the loop. That > is because the while command is on the right-hand side of the pipe > meaning it runs in a subshell. At the end of

Re: Fascinating problem with bash

2010-08-23 Thread Cameron Hutchison
"Oliver Schneider" writes: >Both cases can occur in several places (outer while loop). Since the >paths can contain blanks, I resorted to a "while read" loop because >"for" simply would tokenize the file names more than desirable. As soon as I read this paragraph I saw the problem. I confirmed i

Re: Fascinating problem with bash

2010-08-23 Thread Oliver Schneider
Hi again. On 23.08.2010 21:45, Burton Samograd wrote: > You might have to >> the source file name to a temporary file from > the sourced scripts and then read that after the loop is done. Since > while seems to capture variable setting in its own scope it might be > the only way for what you wa

Re: Fascinating problem with bash

2010-08-23 Thread Burton Samograd
"Oliver Schneider" writes: > Hi folks, > > on my Debian box I'm running GNU bash, version 3.2.39(1)-release > (i486-pc-linux-gnu). > > Now, today I ran across a slight problem that I fail to understand. I > have one script that acts as a library of a kind. I.e. it is being > sourced by other scri