A more complicated and by-foot way. Needs refinement and hardening (format string insertion!). Also IMHO unusable, since this kind of stuff is nothing one wants to do with a shell. I just did it to see if it would work.
Code:
#!/bin/bash
# Testarray
array=(one two three four five)
# Testformat
format="%1%--%0%++%2%,%4%,%3%"
# Format decoder
inside_fieldspec=0
current_element_string=""
element_list=()
elements=()
for ((c=0; c<${#format}; c++)); do
case ${format:c:1} in
"%")
((inside_fieldspec = !inside_fieldspec))
if ((!inside_fieldspec)); then
element_list+=("$current_element_string")
printf_format+="%s"
current_element_string=""
fi
;;
[[:digit:]])
if ((inside_fieldspec)); then
current_element_string+="${format:c:1}"
else
printf_format+="${format:c:1}"
fi
;;
*)
printf_format+="${format:c:1}"
;;
esac
done
for index in "${element_list[@]}"; do
elements+=("${array[index]}")
done
echo "Printf format: '$printf_format'"
echo "Element List: ${element_list[@]}"
echo "Elements: ${elements[@]}"
echo "Result:"
printf "$printf_format\n" "${elements[@]}"