Timeline for bash dynamic (variable) variable names
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 11, 2021 at 8:12 | comment | added | Smar |
@user declare has flag -g to declare variable to be a global.
|
|
| Apr 26, 2020 at 19:50 | comment | added | JepZ |
AFAIK, the eval solution is the only POSIX compliant one.
|
|
| Jun 27, 2019 at 3:21 | comment | added | user |
Note: Using declare only sets the variable in the local scope, while the eval approach sets it globally.
|
|
| May 7, 2016 at 20:01 | vote | accept | giannis christofakis | ||
| Aug 16, 2015 at 19:25 | vote | accept | giannis christofakis | ||
| Aug 16, 2015 at 19:25 | |||||
| Aug 11, 2015 at 18:25 | comment | added | Peter Cordes |
Bash also has a nicer alternative to declare / eval: printf -v varname '%fmt' args. Some bash-completion internal functions use this for call-by-reference. (pass the name of a variable to store into).
|
|
| Aug 11, 2015 at 12:27 | comment | added | heemayl |
Its called indirect expansion of bash parameter expansion..read this
|
|
| Aug 11, 2015 at 12:24 | comment | added | giannis christofakis |
What is the ! exclamation mark printf '%s\n' "${!name}" for?
|
|
| Aug 11, 2015 at 11:48 | history | answered | heemayl | CC BY-SA 3.0 |