1#! /bin/bash 2 3# Format: array_to_string vname_of_array vname_of_string separator 4array_to_string() 5{ 6 (( ($# < 2) || ($# > 3) )) && { 7 "$FUNCNAME: usage: $FUNCNAME arrayname stringname [separator]" 8 return 2 9 } 10 11 local array=$1 string=$2 12 ((3==$#)) && [[ $3 = ? ]] && local IFS="${3}${IFS}" 13 eval $string="\"\${$array[*]}\"" 14 return 0 15} 16