From 3f6c1435a4cbdf73a65639b05898a01c0dfc21ac Mon Sep 17 00:00:00 2001 From: Pete Travis Date: Wed, 1 Oct 2014 11:33:51 -0600 Subject: we might need this sles10 stuff later --- .../bash-3.1-postpatch/examples/functions/array-to-string | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scratch/bash-3.1-postpatch/examples/functions/array-to-string (limited to 'scratch/bash-3.1-postpatch/examples/functions/array-to-string') diff --git a/scratch/bash-3.1-postpatch/examples/functions/array-to-string b/scratch/bash-3.1-postpatch/examples/functions/array-to-string new file mode 100644 index 0000000..0d2fbe5 --- /dev/null +++ b/scratch/bash-3.1-postpatch/examples/functions/array-to-string @@ -0,0 +1,15 @@ +#! /bin/bash + +# Format: array_to_string vname_of_array vname_of_string separator +array_to_string() +{ + (( ($# < 2) || ($# > 3) )) && { + "$FUNCNAME: usage: $FUNCNAME arrayname stringname [separator]" + return 2 + } + + local array=$1 string=$2 + ((3==$#)) && [[ $3 = ? ]] && local IFS="${3}${IFS}" + eval $string="\"\${$array[*]}\"" + return 0 +} -- cgit