diff options
author | Roy Marples <roy@marples.name> | 2007-11-14 18:23:59 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-11-14 18:23:59 +0000 |
commit | 0c25b359de8d4e0900f3ab4bd098736ed97b412d (patch) | |
tree | c6c9937958e6d4da3c9fdc5e242e7db583417e8a /sh | |
parent | a21512847558e2b46c21e970499b5ff75a920cb3 (diff) |
Allow bash arrays to be flattened to make some configs easier.
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/net.sh | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 |