Path: utzoo!attcan!uunet!tank!uxc!iuvax!rutgers!att!cbnews!lml From: lml@cbnews.ATT.COM (L. Mark Larsen) Newsgroups: comp.unix.wizards Subject: Re: Set parent env with csh script Message-ID: <3023@cbnews.ATT.COM> Date: 10 Jan 89 23:30:29 GMT References: <174@v7fs1.UUCP> <9314@smoke.BRL.MIL> <1291@uwbull.uwbln.UUCP> Reply-To: lml@cbnews.ATT.COM (L. Mark Larsen) Distribution: world,comp Organization: AT&T Bell Laboratories Lines: 35 In article <1291@uwbull.uwbln.UUCP> ckl@uwbln.UUCP (Christoph Kuenkel) writes: # ...Bourne shell does it right, but attention, in # # while ; do # # done # # is executed in a ``subrocess context'' due to the io redirection! # So any variable assignement and/or environment setting is uneffective outside # the while-loop. # Any elegant solution to that? # # christoph By putting the loop into a function and redirecting at the function call, the variables set in the function will still be in effect outside of the while loop. For example: func () { while ; do done } func This works with sh. Incidently, ksh does not share the "feature" of sh that force while and for loops to be executed in a subprocess, so this kind of trick is not necessary. Elegant? You decide. L. Mark Larsen lml@atlas.att.com att!atlas!lml