Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site callan.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!houxm!whuxl!whuxlm!akgua!sdcsvax!sdcrdcf!trwrb!scgvaxd!wlbr!callan!tim From: tim@callan.UUCP (Tim Smith) Newsgroups: net.unix-wizards Subject: Re: shell bug I reported here a few days ago Message-ID: <313@callan.UUCP> Date: Fri, 8-Mar-85 19:40:18 EST Article-I.D.: callan.313 Posted: Fri Mar 8 19:40:18 1985 Date-Received: Sun, 10-Mar-85 07:50:47 EST Reply-To: tim@callan.UUCP (Tim Smith) Organization: Callan Data Systems, Westlake Village, CA Lines: 33 Summary: A few days ago, I mentioned here that the sh command for i in x do foo=bar done < /dev/null failed to work. The assignment was not done. When IO was not redirected, it worked. It has since been pointed out to me that the for loop is run in a subshell when IO is redirected, so of course, the assignment does not have any effect outside the loop. This does seem to be the case. So why is it done like this? Why must the for loop be a subshell? After finding out the above, I tried the following: parent # parent prints the pid of its parent foo=bar if true then parent foo=spam fi < /dev/null echo $foo This one is NOT running in a subshell, but the assignment STILL fails. When IO is not redirected, the assignment works. What is going on in this case? Note: the first example was tried on both a UniSoft port of Sys V and on the system III sh. I have only tried the second on the Sys V sh. -- Duty Now for the Future Tim Smith ihnp4!wlbr!callan!tim or ihnp4!cithep!tim