From 0c25b359de8d4e0900f3ab4bd098736ed97b412d Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 14 Nov 2007 18:23:59 +0000 Subject: Allow bash arrays to be flattened to make some configs easier. --- sh/net.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sh/net.sh') diff --git a/sh/net.sh b/sh/net.sh index 1ae030f7..74b3ac80 100755 --- a/sh/net.sh +++ b/sh/net.sh @@ -87,6 +87,26 @@ _get_array() { [ -n "${_a}" ] } +# Flatten bash arrays to simple strings +_flatten_array() { + if [ -n "${BASH}" ] ; then + case "$(declare -p "$1" 2>/dev/null)" in + "declare -a "*) + eval "set -- \"\${$1[@]}\"" + for x in "$@"; do + printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")" + done + return 0 + ;; + esac + fi + + eval _a=\$$1 + printf "%s" "${_a}" + printf "\n" + [ -n "${_a}" ] +} + _wait_for_carrier() { local timeout= efunc=einfon -- cgit v1.2.3