Subject: | |
From: | |
Reply To: | |
Date: | Sat, 7 Jun 2014 04:28:32 +0000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Actually, it would be good if someone with a good deal of bash
scripting experience chimed in.
eval is not safe to use in a bash script. If the input is crafted
cleverly, the script can execute unwanted commands. Not to mention the
above examples don't work great with characters like "!" which are
evaluated as the built-in history command by eval. You need to
actually escape my example with backslashes for that reason.
Brandon Vincent
On Sat, Jun 7, 2014 at 4:25 AM, ToddAndMargo <[log in to unmask]> wrote:
>> On Sat, Jun 7, 2014 at 3:52 AM, ToddAndMargo <[log in to unmask]>
>> wrote:
>>>
>>> Hi All,
>>>
>>> In Bash script language, how do I create a variable name
>>> from a variable?
>>>
>>> I am trying to create a variable called "abcStatus"
>>>
>>> x=abc
>>> $xStatus=xyz
>>>
>>> obviously doesn't work. What am I doing wrong?
>>>
>>> Many thanks,
>>> -T
>>
>>
>
> On 06/06/2014 09:14 PM, Brandon Vincent wrote:> There is probably a better
> way, (bash declare perhaps?), but:
>
>>
>> x=abc
>> eval $(echo $x)Status="This works!"
>>
>> Brandon Vincent
>>
>
> Hi Brandon,
>
> I completely blanked on "eval". Thank you!
>
>
> -T
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|