3 ms·
with bash namerefs, having a function like split-on-ddash outputa outputb a b c -- x y z for x in "${outputa[@]}"; do # ... becomes feasible. Of cours
by its-summertime 1y ago
with bash namerefs, having a function like
split-on-ddash outputa outputb a b c -- x y z
for x in "${outputa[@]}"; do # ...
becomes feasible. Of course, don't do it.
- alurm 1y agoSure. I have tried Bash namerefs. I found them to be kinda awkward, since you need to name them uniquely. So, you have to pretend that they are global variables, even though they are declared inside a function, which makes their usage verbose. Here, this could look like: split_by_double_dash() { declare -n split_by_double_dash_before=$1 declare -n split_by_double_dash_after=$2 split_by_double_dash_before=() split_by_double_dash_after=() ... }