Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!emcard!wa4mei!nanovx!msa3b!kevin From: kevin@msa3b.UUCP (Kevin P. Kleinfelter) Newsgroups: comp.unix.questions Subject: Bourne Shell FOR loop confusion Keywords: why does it do this Message-ID: <689@msa3b.UUCP> Date: 1 Aug 89 13:16:03 GMT Organization: Management Science America, Inc., Atlanta, GA Lines: 41 Would anyone who knows, please explain the following behavior? (Post or e-mail, as you deem appropriate.) I enter the following: x=x for i in abc do x=$i done echo $x The output is, as expected, "abc". Then I enter the following: y=y for i in abc do y=$i done < /dev/null echo $y The output is "y", which is exactly what I want to know! ("why"). ***************************************** What I really want to do is to redirect input to "read", but read is non-redirectable (according to my doc, and experience on my system). I was going to attemtpt this as follows for i in 1 do read a b c done < /tmp/foo If I "echo a, b, c" inside the loop, I get the expected values from the file. If I "echo a, b, c" after the loop, I see that they have reverted to their values prior to the loop. Korn Shell has a nice way to resolve this, via an option to "read" to read from a specific file handle. Bourne Shell doesn't. I'm stuck with a system that does not have Korn Shell. :-( -- Kevin Kleinfelter @ Management Science America, Inc (404) 239-2347 gatech!nanovx!msa3b!kevin