Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: csh setenv problem Message-ID: <13663@bloom-beacon.MIT.EDU> Date: 20 Aug 89 19:58:21 GMT References: <2312@zaphod.axion.bt.co.uk> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 42 In article <2312@zaphod.axion.bt.co.uk> iwarner@zaphod.axion.bt.co.uk writes: > The Bourne Shell (sh) has an export command, which exports >a variable to the parent shell. Csh does not have this. In a word, wrong. There is no mechanism for passing environment variables from a child process back to its parent. It can't be done. Unless you hack in some form of interprocess communication between two processes whose source code you write yourself, so that they can pass variables back and forth along a pipe or something, and deal with them appropriately. Like csh, sh has two different kinds of variables, environment variables and local shell variables. When you set a variable with the command "FOO=bar", you create a local variable with that value (if the variable did not already exist), or change the value of the local variable (if it already existed as a local variable), or change the value of the environment variable (if it already existed as an environment variable). The command "export FOO" does NOT send the value of FOO to the parent process of the shell, it changes FOO from a local variable into an environment variable, so that child processes will inherit the variable. Observe: Script started on Sun Aug 20 15:35:18 1989 achates% /bin/sh $ /bin/sh # There are now two sh's running, and # one is the child of the other $ FOO=bar; export FOO $ echo $FOO bar # FOO is an environment variable in # the child sh $ ^D$ echo $FOO # ^D exits from the child shell # The line is blank, because FOO has $ ^Dachates% exit # no value in the parent sh script done on Sun Aug 20 15:36:20 1989 Jonathan Kamens USnail: MIT Project Athena 432 S. Rose Blvd. jik@Athena.MIT.EDU Akron, OH 44320 Office: 617-253-4261 Home: 216-869-6432