source:
vendor/bash/3.1-p17/examples/functions/array-to-string
Last change on this file was 3228, checked in by , 18 years ago | |
---|---|
File size: 340 bytes |
Line | |
---|---|
1 | #! /bin/bash |
2 | |
3 | # Format: array_to_string vname_of_array vname_of_string separator |
4 | array_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 | } |
Note:
See TracBrowser
for help on using the repository browser.