Patch-ID: bash41-003
[bash.git] / examples / functions / array-to-string
blob0d2fbe50552f566a9cd13f82072a7706ede5b66b
1 #! /bin/bash
3 # Format: array_to_string vname_of_array vname_of_string separator
4 array_to_string()
6 (( ($# < 2) || ($# > 3) )) && {
7 "$FUNCNAME: usage: $FUNCNAME arrayname stringname [separator]"
8 return 2
11 local array=$1 string=$2
12 ((3==$#)) && [[ $3 = ? ]] && local IFS="${3}${IFS}"
13 eval $string="\"\${$array[*]}\""
14 return 0