Maja changed the topic of ##bash-crimes to: we bash back | club of folks preoccupied in whether they could, not whether they should | logs https://libera.irclog.whitequark.org/~h~bash-crimes
famfo has quit [*.net *.split]
tastytea has quit [*.net *.split]
tastytea has joined ##bash-crimes
famfo has joined ##bash-crimes
jn has quit [Ping timeout: 272 seconds]
jn_ has joined ##bash-crimes
jn_ has joined ##bash-crimes
dakkar has joined ##bash-crimes
<sdomi> $ declare -A a[meow]='(())'
<sdomi> bash: syntax error near unexpected token `('
<sdomi> i love this. it happens only when parenthesis are first thing in the assignment
<sdomi> and even better, only when manually using declare
<sdomi> (lore: I need `declare -g -A $dynamic[$i]='<arbitrary data>'` and due to the array name being dynamic, i can't do the assignment regular way)
<dakkar> namerefs?
<sdomi> i need to make a copy of an associative array, just taking a ref won't do
<sdomi> not necessarily proud of this code, but I didn't find any better way that would preserve the indice names
<isabella> you want eval
<dakkar> thing="$(declare -p $nested_ref)";eval "${thing//declare -A $nested_ref/declare -g -A _$nested_id}"
<dakkar> (vaguely tested)
<sdomi> eval pains me
<isabella> you want source <(echo ...)
<isabella> what you wrote is an eval sdomi
<sdomi> eh, i suppose
<sdomi> not sure how much I trust `declare -p` after i've seen it badly mangle some arrays with special characters (that could be otherwise accessed just fine)
<dakkar> oh, you've seen worse horrors than me then
<dakkar> (I'm usually the one *generating* the horrors…)
<sdomi> sadly no example on hand, but that was back when i was hacking on a test harness that generated random data
<sdomi> curiously, doing this straight up with eval reverses the indice order for me <.<
<sdomi> i'm not relying on that anywhere, but it's funny to see
<dakkar> associative arrays are not ordered, are they?
<sdomi> they're ordered on an internal hash of something
<sdomi> beyond that, not really
<dakkar> yeah, so "reverses the order" is a special case of "the order is unpredictable", right?
<sdomi> more or less :p
dakkar has quit [Ping timeout: 246 seconds]
<sdomi> i have been informed of the following trick by Maja:
<sdomi> : "${arr[@]@A}"
<sdomi> declare -${arr@a} newarr="${_#*=}"
<sdomi> and i'm both in awe and flabbergasted
<Maja> also works if instead of : you do echo
<isabella> that's smart
<isabella> ${arr@a} smart
<sdomi> Maja: you're insane, has anyone ever told you that? /pos