[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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 09:44:51 -0400 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
Before even reading the body, responding only to the subject:
Use an associative array instead.
On Tue, Jul 03, 2018 at 10:09:24PM +1000, Robert Durkacz wrote:
> How could I write a shell script that takes two arguments, the first to be
> interpreted as the name of an environment variable and the second to be the
> value of that variable? All the script should do is create an environment
> variable with that value.
A script CAN'T set an environment variable. Once the script exits, that
variable will be gone.
A script is a separate child process with its own copy of the environment,
and any changes it makes to its environment will not be visible to its
caller.