if i export a variable it exports to its child only.
how can i export variables from child shell to parent?
Printable View
if i export a variable it exports to its child only.
how can i export variables from child shell to parent?
lak wrote:[color=blue]
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?
>[/color]
You can't.
Robert
On 2007-10-18, lak wrote:[color=blue]
>
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?[/color]
You can't.
However, you can have a script print a value and assign that to a
variable in the parent:
val=$( your_script )
If you need to set more than one variable, have the script (or a
command that allows formatting of its output) print assignment
statements and use eval:
eval "$( date +"year=%Y month=%m day=%d" )"
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
On Oct 18, 7:20 am, lak <lakindi...@gmail.com> wrote:[color=blue]
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?[/color]
"Source" the child shell. That is, instead of executing it with:
myshell
run it in the local shell by prepending a period and space:
. myshell
--
Fred Kleinschmidt
[email]fred.l.kleinschmidt@boeing.com[/email] writes:[color=blue]
>On Oct 18, 7:20 am, lak <lakindi...@gmail.com> wrote:[color=green]
>> if i export a variable it exports to its child only.
>> how can i export variables from child shell to parent?[/color]
>
>"Source" the child shell. That is, instead of executing it with:
> myshell
>run it in the local shell by prepending a period and space:
> . myshell
>[/color]
potentially dangerous. exit, for example, has significantly
different effect if it is sourced vs. execed.
scott