Path: utzoo!attcan!uunet!netagw!samt19!hqda-ai!cos!hadron!decuac!shlump.nac.dec.com!decwrl!wuarchive!cs.utexas.edu!rice!uw-beaver!tektronix!reed!pzbaum!omepd!merlyn From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions Subject: Re: How Does One Change Variables That Are Set From A Sub-Shell Keywords: csh, programs, lunch, variables, set Message-ID: <5253@omepd.UUCP> Date: 23 Nov 89 00:51:37 GMT References: <1989Nov20.190903.27550@wucs1.wustl.edu> <1989Nov21.052026.11968@athena.mit.edu> Sender: news@omepd.UUCP Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 35 In-reply-to: jik@athena.mit.edu (Jonathan I. Kamens) In article <1989Nov21.052026.11968@athena.mit.edu>, jik@athena (Jonathan I. Kamens) writes: | In article <1989Nov20.190903.27550@wucs1.wustl.edu> flan@ai.wustl.edu (Ian "No | Excuse" Flanigan) writes: | > How does one pass a csh variable back to the old csh -or- grab said | > variable from a currently running shell and then feed it back. | | You cannot pass environment variables or shell variables from a | sub-shell back to its parent, and you cannot (without reading the | memory image of the running sub-process in order to find the value of | the variable) "grab" a variable from a sub-process in order to set its | value in another process' environment. | | The only way this would be possible is if the parent and child | defined some special protocol (using a pipe, socket, whatever) for | transferring variable names and values between themselves. None of | the "standard" shells (sh, csh, tcsh, ksh, bash, whatever) have any | facility for doing this, at least not that I know of. However, reaching into my bag of nifty /bin/sh tricks, I could do something like: trap '. $HOME/.doit; /bin/rm -f $HOME/.doit' 4 (/my/background/process $$)& where "/my/background/process" is responsible for putting some /bin/sh commands, like: PS1="${PS1L}YOU HAVE MAIL ${PS1R}" into $HOME/.doit, and sending the shell (as passed by the first arg, a signal 4). The detailed implementation is left as an exercise to the reader. :-) Just another shell wizard,