tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Help appreciared on the , init S command

Solaris 8 Intel - won't use my PS/2 mouse ▻

Environmental variable questions

In article <38EEBD3A.6692FEC8@yahoo.com>, Alan  <alan_psb@yahoo.com> wrote:
>1) Is the environmental variable setting in script file does not affect
>the current shell environmental variable?

Correct.

>2) How about the other shells (e.g. sh)? Is it the same in other shells
>(i.e. change the value of environmental variable does not affect the
>current shell variable)

Yes.  The script is run as a separate process.  In Unix, changes in one
process do not affect any other processes.  You can't write a script
that will change the invoking shell's environment, current directory,
umask, process limits, etc., which is why these are all builtin shell
commands.

>3) How can I change the value of the current shell environmental
>variable in a script file?

You need to arrange for the shell to run the script without starting a
new process.  In csh, use the `source' builtin; in other shells use `.'.

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell,comp.unix.solaris
Subject: Re: Environmental variable questions
Date: 12 Apr 2000 12:52:33 +0100
Message-ID: <8d1o2n$7s3$1@ltpcg.star.le.ac.uk>
References: <38EEBD3A.6692FEC8@yahoo.com>

△ comp.unix.shell △

◅ Help appreciared on the , init S command

Solaris 8 Intel - won't use my PS/2 mouse ▻