summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2013-08-23 11:14:08 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2013-08-23 11:14:08 -0500
commit56dd91ee7737dd3d4ebc57185632f407a2cdf3c1 (patch)
tree46b793cfeedfeee943b20abc3f4ed3974213d15f
parentrename package to netifrc (diff)
downloadnetifrc-remove-bash-arrays.tar.gz
netifrc-remove-bash-arrays.tar.bz2
netifrc-remove-bash-arrays.zip
remove support for bash arraysremove-bash-arrays
-rw-r--r--init.d/net.lo.in61
1 files changed, 4 insertions, 57 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index a4e65e9..949f24e 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -48,59 +48,6 @@ depend()
done
}
-# Support bash arrays - sigh
-_array_helper()
-{
- local _a=
-
- eval _a=\$$1
- _a=$(echo "${_a}" | sed -e 's:^[[:space:]]*::' -e 's:[[:space:]]*$::' -e '/^$/d' -e 's:[[:space:]]\{1,\}: :g')
-
- [ -n "${_a}" ] && printf "%s\n" "${_a}"
-}
-
-_get_array()
-{
- local _a=
- if [ -n "${BASH}" ]; then
- case "$(declare -p "$1" 2>/dev/null)" in
- "declare -a "*)
- ewarn "You are using a bash array for $1."
- ewarn "This feature will be removed in the future."
- ewarn "Please see net.example for the correct format for $1."
- eval "set -- \"\${$1[@]}\""
- for _a; do
- printf "%s\n" "${_a}"
- done
- return 0
- ;;
- esac
- fi
-
- _array_helper $1
-}
-
-# Flatten bash arrays to simple strings
-_flatten_array()
-{
- if [ -n "${BASH}" ]; then
- case "$(declare -p "$1" 2>/dev/null)" in
- "declare -a "*)
- ewarn "You are using a bash array for $1."
- ewarn "This feature will be removed in the future."
- ewarn "Please see net.example for the correct format for $1."
- eval "set -- \"\${$1[@]}\""
- for x; do
- printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
- done
- return 0
- ;;
- esac
- fi
-
- _array_helper $1
-}
-
_wait_for_carrier()
{
local timeout= efunc=einfon
@@ -433,8 +380,8 @@ _load_modules()
_load_config()
{
- local config="$(_get_array "config_${IFVAR}")"
- local fallback="$(_get_array fallback_${IFVAR})"
+ eval local config="\$config_${IFVAR}"
+ eval local fallback="\$fallback_${IFVAR}"
config_index=0
local IFS="$__IFS"
@@ -638,10 +585,10 @@ start()
local hideFirstroute=false first=true routes=
if ${fallback}; then
- routes="$(_get_array "fallback_routes_${IFVAR}")"
+ eval routes="\$fallback_routes_${IFVAR}"
fi
if [ -z "${routes}" ]; then
- routes="$(_get_array "routes_${IFVAR}")"
+ eval routes="\$routes_${IFVAR}"
fi
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
if [ "${config_0}" != "null" ]; then