Re: How to set environment variable



On 9/27/07, hwigoda@xxxxxxxxxxxxxx <hwigoda@xxxxxxxxxxxxxx> wrote:
can't you set the environmental variables for the parent shell
by running a script as a . or here file?
snip

When you use Korn, Bourne, BASH, etc. and say ". " or "source " before
a script, it runs in the current process (i.e. the interpreter is the
same one that responds to you interactively). Any command in the
script is handled as if you had typed it into the command line. This
is why shell scripts run with ". " can modify the environment. If
your shell could execute Perl code then Perl would be able to modify
the environment as well, but most shells cannot execute Perl code
natively (the only ones I am aware of are zoidberg* and psh**) and
must open a new process for the Perl interpreter.

* http://search.cpan.org/dist/Zoidberg/lib/Zoidberg.pm
** http://sourceforge.net/projects/psh/
.



Relevant Pages

  • Re: [PATCH] Linux 2.6: shebang handling in fs/binfmt_script.c
    ... script files and their interpreters (shells, awk, perl, python, guile, ... that that shell or interpreter would be poorly ... And, to be truthful, the usual way that I code awk scripts is not as ...
    (Linux-Kernel)
  • Re: #! vs : use ?
    ... colon is basically an evaluated commented - a shell builtin for /bin/ ... Configure script knows a lot about *ix history) Configure script. ... doesn't recognise any shebang mechanism. ... interpreter when a file was starting with "#!". ...
    (comp.unix.shell)
  • cron shell scripts Summary
    ... I am fully aware of the Best Practice for shell scripts whereby the ... script I wrote ... This lead me to the incorrect conclusion that the CRON daemon simply ... schedule it into cron which will use its default interpreter: ...
    (SunManagers)
  • Re: can a shell script be an "interpreter"
    ... interpreter and bc ignore that shell part. ... syntax errors. ...
    (comp.unix.shell)
  • Re: Executable shell scripts
    ... Anyhow, I don't really mind the 111 mode, the point was to show shell ... namely setuid and setgid scripts. ... approach is used to pass the file to the interpreter. ... Create a symlink to the script, and just at the right time between the ...
    (Linux-Kernel)