Reputation: 11949
I am using a bash script to generate a list of files, where each file name might contain spaces (it is on Windows, with Git Bash, and I need something that works with Bash 3).
The script does roughly that:
_my_function() {
for i; do
echo $i
done
}
_test() {
local do_add_list
do_add_list[0]='Some file'
do_add_list[1]='Another file'
_my_function $do_add_list[@]
}
While I don’t really want to pass the array as is, I’d like to pass it as arguments of _my_function
like xargs
or as something like,
_my_function 'Some file' 'Another file'
How can I do that in Bash 3 (msys port of bash3), apart from as a global variable?
Upvotes: 1
Views: 385
Reputation: 33317
Instead of
_my_function $do_add_list[@]
do
_my_function "${do_add_list[@]}"
Upvotes: 6