Re: How can I set an environment variable of the current shell?



On 2008-04-18, Joachim Gann <joachim.gann@xxxxxxxxx> wrote:

a process can alter its own environment via the putenv() system call.
your shell just keeps its own list of variable/value pairs and puts
the exported ones into the environment of spawned child processes.
perl language designers have included a language element to allow you
to do putenv() whereas shell language designers seem to have not done
so.
but why would you care? what would a (hypothetical) "shell_putenv()"
give you that is superior to "FOO=BAR" or "export FOO=BAR" ?

In the .profile, an environment variable (SYMCLI_DB_FILE) is set
containing the location of a file which is used by some storage array
management software (SYMCLI). When someone starts a long-running SYMCLI
command, SYMCLI locks the file and some other SYMCLI commands won't run
until the long-running command is done. To circumvent this, it's
perfectly OK to point SYMCLI_DB_FILE to another file. This way, when
one long-running command locks one file, you can issue another
long-running command using the other file.

I'm trying to add a check to .profile to see which files are already pointed
to by the different instances of SYMCLI_DB_FILE on the system, and then
point SYMCLI_DB_FILE of the currently logging in shell to an unused file.

To do this, I want to see (from the outside) to which file each instance of
SYMCLI_DB_FILE points to. I can't do this if the shell doesn't alter its own
environment when a shell environment variable is set.

Of course, there could very well be better ways to achieve this goal,
but I became curious and now want to know the nitty gritty details of
environment variables. :)

--
Jurjen Oskam

Savage's Law of Expediency:
You want it bad, you'll get it bad.
.



Relevant Pages

  • Re: Environment variable not remembered outside a script?
    ... After executing the two files (.zshrc is already executed when I opened the ... This is a difference between running a script and sourcing it. ... and any environment variables it sets are ... themselves are not a shell feature but are actually part of the UNIX ...
    (comp.unix.shell)
  • Re: Process Understanding
    ... their environment, especially env variables. ... the that one user has a bash shell while the other has no shell ... The environment variables are read by software commands. ... Now when you execute the source command again, ...
    (Fedora)
  • Re: Export command
    ... exporting a shell variable means marking that shell variable as ... The environment on Unix is a list of strings passed from command ...
    (comp.unix.shell)
  • Re: How can I set an environment variable of the current shell?
    ... I'm trying to set an environment variable of the current shell process. ... verify $FOO isn't currently set as a shell variable: ... It isn't specific to AIX ksh, the OpenBSD ksh behaves the same. ...
    (comp.unix.aix)