Re: [Help-bash] taking the name of a variable from another variable
From:
Greg Wooledge
Subject:
Re: [Help-bash] taking the name of a variable from another variable
Date:
Tue, 3 Jul 2018 11:17:02 -0400
User-agent:
NeoMutt/20170113 (1.7.2)
On Tue, Jul 03, 2018 at 04:21:55PM +0200, Marco Ippolito wrote:
> then perhaps
> something as simple as this is enough to set your environment variable:
>
> name=foo value=bar; eval "export $name=$value"
That's an unsafe use of eval. You need to escape the $ before value,
so that after the eval, the shell ends up running:
export foo=$value
All other points (child processes, environment, sourcing) still apply.