Skip to main content
9 events
when toggle format what by license comment
Jun 4, 2022 at 2:38 comment added muru @ebsf I believe what it means is that you can't have something like declare -an foo=(...) where a variable is both an array and a nameref. Having an array foo and then doing declare -n bar=foo has worked fine for years, e.g., another answer from 7 years ago on this post, or this answer from me on U&L from 5 years ago
Jun 3, 2022 at 18:13 comment added ebsf @muru, what do you make of the statement in man bash-builtins (for the declare -n option, which local incorporates): "The -n attribute cannot be applied to array variables." I don't know enough yet to understand how this fits, except to know that absent other input such as your suggestion, the statement would, in my ignorance, discourage me from using the -n option in this situation.
Feb 7, 2020 at 9:28 comment added tisc0 Just posted a proposition : pass one or multiple strings and make them an array inside the function.
S Jul 12, 2018 at 7:49 history suggested Stephen Rauch CC BY-SA 4.0
Remove extra commentary
Jul 12, 2018 at 4:04 comment added muru That is ugly and unncessary. If you want to pass the array by name, make array_internally an alias of it: declare -n array_internally=$1. And the rest of it about "becomes complicated" and "determine and then remove ..." applies to irrespective of how you pass the array, so I don't see what's the point of that. And evaling an array potentially containing special characters is just waiting for grief to happen at a later date.
Jul 12, 2018 at 0:03 review Suggested edits
S Jul 12, 2018 at 7:49
Jul 11, 2018 at 22:26 review Late answers
Jul 11, 2018 at 22:38
Jul 11, 2018 at 22:06 review First posts
Jul 12, 2018 at 0:03
Jul 11, 2018 at 22:02 history answered Blake Schultze CC BY-SA 4.0