[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Functions takes arrays and outputting another array
From: |
uzibalqa |
Subject: |
Functions takes arrays and outputting another array |
Date: |
Fri, 31 Mar 2023 16:58:35 +0000 |
I want to make a bash function that takes two arrays and outputs another array.
Here I use "typeset". Should I use "declare" instead as in (declare -n
_array1="$1" _array2="$2") ?
For the output, I have thought about introducing a null. Is this the correct
way to output arrays
from a function?
fill_array()
typeset -n _array1="$1" _array2="$2"
typeset _ext
for _ext in "${_array1[@]}"; do
case $_ext in
(PEXTD) _out+=( '--include=*.'{cp,cpp,f90,f95,f03,f08} ) ;;
(PROGL) _out+=( '--include=*.'{rc,el,c,f} ) ;;
(TYPOG) _out+=( '--include=*.'{org,texi,tex} ) ;;
(*) continue
esac
printf '%s\0" "${_out[@]}"
done
}
- Functions takes arrays and outputting another array,
uzibalqa <=