sh & export
Fbsd8
fbsd8 at a1poweruser.com
Tue Jan 29 01:17:16 UTC 2013
kpneal at pobox.com wrote:
> On Mon, Jan 28, 2013 at 07:41:35PM -0500, Fbsd8 wrote:
>> This is what I am looking at in a sh script
>>
>> echo export jail_${jailname}_hostname=\"${jailname}\"
>> puts it into the env
>> and this brings it back out
>> eval jailname=\"\$jail_${jailname}_hostname\"
>>
>> Question is how can I display from the console command
>> line what has been exported?
>>
>> env issued on the console command line does not show
>> any thing named jail.
>
> Environment variables are only exported to children of the shell that
> created or inherited them. When you run a script you normally have your
> command line shell start a child shell which then executes the script.
> When the child shell that runs the script finishes the script it ends and
> control returns to the parent. The child's environment at this point is
> gone, but the parent couldn't have looked at it anyway. Parents don't
> really know what their children are doing.
>
> So, to answer your question above, "You can't display from the console
> what was set in a script."
OK then from within a script what single command would show everything?
I tested with a script with only the env command and did not get any
thing more than issuing env from the console command line.
More information about the freebsd-questions
mailing list