From: Steven Smith <sos22@cam.ac.uk>
To: ramzez <r4mz3z@yahoo.es>
Cc: linux-newbie@vger.kernel.org
Subject: Re: export variables
Date: Fri, 24 Jan 2003 17:37:32 +0000 [thread overview]
Message-ID: <20030124173732.GA5031@cam.ac.uk> (raw)
In-Reply-To: <200301240748.03285.r4mz3z@yahoo.es>
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
> - -------------- test.sh ------------------
> export MY_VAR="SOME_VALUE"
> echo "$MY_VAR"
> - -------------- test.sh ------------------
> later: chmod +x test.sh then run this script: ./test.sh
>
> but when try to use this variable in my environment I can't do, if write
> "env" the nev variable MY_VAR doesn't appear ... I think that there are some
> protection about export variables, but how do I can export variables?
The environment of a process cannot easily be changed from outside
that process once the process has started running. This means that
exporting a variable does not do the obvious thing: if you run
a shell script, which tries to export a variable, then that variable
will only be exported to processes which are spawned by that shell
script. In particular, if test.sh contains
export WIDGET=wobble
then running test.sh will have absolutely no effect on the environment
of the shell which invoked it.
If you need to change a running shell's environment through a script,
then you need to get that shell to source rather the script rather
than to execute it. To do this, go
$ . ./test.sh
This causes the shell to run test.sh as if it had been typed in at
the command line, rather than spawning an entirely independent shell
and running test.sh through that.
Steven Smith,
sos22@cam.ac.uk.
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2003-01-24 17:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-24 7:47 export variables ramzez
2003-01-24 13:59 ` Jude DaShiell
2003-01-24 17:37 ` Steven Smith [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030124173732.GA5031@cam.ac.uk \
--to=sos22@cam.ac.uk \
--cc=linux-newbie@vger.kernel.org \
--cc=r4mz3z@yahoo.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox