From: gnewman@world.std.com (Gary Newman)
Subject: Re: Passing Environment Variables
Date: Mon, 20 Mar 1995 20:50:13 GMT [thread overview]
Message-ID: <D5rB7p.9Bw@world.std.com> (raw)
In-Reply-To: 16MAR95.21162637@shrsys.hslc.org
Alan Simon (simon@shrsys.hslc.org) wrote:
: I know that the export command passes variables from the shell down to
: subshells. How do I pass a variable from a subshell back up to the original
: shell?
Strictly speaking, you can't do that in UNIX. However, you can have the
subshell echo a value to standard output, and store the output in a
variable in the parent shell using back-quotes. For example,
in the parent shell:
...
VALUE=`myscript arg1 arg2 ...`
echo VALUE is $VALUE
...
and in 'myscript':
...
echo "Return value"
exit 0
Or, just send different exit codes back to the parent, and test
the $status variable (cshell) or $? variable (bourne shell).
Hope this helps.
--
-------------------------------------------------------------------
Bill O'Keefe |Internet: bokeefe@xmx.com
XMX Corporation |
46 Manning Road |Telephone: (508)670-8444
prev parent reply other threads:[~1995-03-20 20:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-03-16 21:16 Passing Environment Variables Alan Simon
1995-03-20 20:50 ` Gary Newman [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox