On Tue, Oct 20, 2020 at 04:57:36PM -0700, L A Walsh wrote: > > > On 2020/10/20 01:29, Andreas Kusalananda Kähäri wrote: > > > > In bash 4.3+, I would manke your "ar" variable a name reference variable > > instead: > > > > $ ar1=(1 2 3 44) > > $ declare -n ar=ar1 > > $ echo "${#ar[@]}" > > 4 > > > Ya, I was trying to use the 'byname' feature for older/wider support...sigh
Well, your Subject: says bash 4.4.12. If you're really targeting bash 4.4, you should be able to use namerefs, such as they are. If you can't use namerefs (because you're targeting something other than what you said in the Subject:), then your next step would probably be eval. Overall, though, it sounds like you're writing something that's simply too complicated for bash to do well. Consider using another language, or simplifying your data structures to eliminate this indirection. If the X in your X-Y problem is "I'm trying to write a reusable function that takes an array passed by name", then I refer you to <https://mywiki.wooledge.org/BashWeaknesses>.