[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue declaring an array via a variable name
From: |
Hunter Wittenborn |
Subject: |
Issue declaring an array via a variable name |
Date: |
Sat, 14 Aug 2021 16:53:38 -0500 |
User-agent: |
Zoho Mail |
Hi!
I wasn't sure if this was a bug (though it seemed quite likely for me), so I
went ahead and decided to post the issue here before resorting over to the bug
mailing list.
Anyway - For some reason, the following code keeps failing whenever I run it:
"
variable="hello"
declare -g "${variable}"=("world" "me")
"
When run, it's complaining about a syntax error near "(", appearing to be on
the 'declare' line right next to where I start typing the array.
In my testing, all of the following would fail:
- declare -g "${variable}"=("world" "me")
- declare -g ${variable}=("world" "me")
- declare -g "hello"=("world" "me")
The only one that did work was the following:
- declare -g hello=("world" "me")
Is there a valid reason why this isn't working (besides it just being a bug)?
If there is, is it possible to implement it otherwise so I can use it?
---
Hunter Wittenborn
https://www.hunterwittenborn.com
https://github.com/hwittenborn
- Issue declaring an array via a variable name,
Hunter Wittenborn <=