Subshell Variable

Leo de Wit leo at philmds.UUCP
Sun Feb 26 23:25:47 AEST 1989


In article <424 at unicom.UUCP> sayah_k at 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.



More information about the Comp.unix.questions mailing list