by its-summertime · 1y ago · 0 comments
split-on-ddash outputa outputb a b c -- x y z
for x in "${outputa[@]}"; do # ...
becomes feasible. Of course, don't do it.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=()
...
}