Xref: utzoo comp.unix.questions:11886 comp.unix.wizards:14855 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Subshell Variable Keywords: Subshell Variable Message-ID: <963@philmds.UUCP> Date: 26 Feb 89 13:25:47 GMT References: <424@unicom.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 34 In article <424@unicom.UUCP> sayah_k@unicom.UUCP (KIANUSCH... Yes, Kianusch himself !!!) writes: |Is there a way to exports system-variables from subshell, running in background |to the main shell? | |I tried and tried and tried... but with no results... :-( | You haven't tried the following (assuming you don't need signal 5 in the main shell). You can use it in all kinds of ways to communicate between a parent and its child shell; I saw the idea first presented by Maarten Litmaath to implement a 'cd with prompt-to-path conversion' kind of cd alias for the Bourne shell. Script started on Sun Feb 26 13:51:22 1989 philmds> trap ". .readvar" 5 philmds> trap 5: . .readvar philmds> (echo "NEWVAR=newvalue export NEWVAR" >.readvar; kill -5 $$)& 19795 philmds> [1] Done ( echo "NEWVAR=newvalue export NEWVAR"; kill -5 $$ ) philmds> echo $NEWVAR philmds> echo $NEWVAR newvalue philmds> script done on Sun Feb 26 13:55:43 1989 Note the somewhat peculiar behaviour of the main shell: the trap seems to be honoured only after execution of the next command. Maybe someone else has a reasonable explanation of this? Leo.