summaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2011-09-21 00:21:43 +0200
committerChristian Ruppert <idl0r@gentoo.org>2011-09-21 00:21:43 +0200
commit930f4021b1904b9c46c41c70b99d6e0620a1b59d (patch)
tree6519d98ac7db73f968760eef491c1f25ccc8ce0a /init.d
parentbf49e59e3eb4fe12167812bc1b4531742eddc383 (diff)
downloadopenrc-930f4021b1904b9c46c41c70b99d6e0620a1b59d.tar.gz
openrc-930f4021b1904b9c46c41c70b99d6e0620a1b59d.tar.bz2
openrc-930f4021b1904b9c46c41c70b99d6e0620a1b59d.tar.xz
Add a new helper functions for _{flatten,get}_array
A new helper function (_array_helper) since both, the _flatten_array and _get_array function share partially the same code. We also reduce multiple whitespace to a single space, remove leading newlines as well as skipping "empty" lines. This makes the data returned by _{flatten,get}_array much nicer than before. It also fixes bug 366677 where net-tools having trouble with the whitespace mentioned above. iproute2 was not affected. Reported-by: Andrew Maltsev <am@ejelta.com> X-Gentoo-Bug: 366677 X-Gentoo-Bug-URL: https://bugs.gentoo.org/366677
Diffstat (limited to 'init.d')
-rw-r--r--init.d/net.lo.in19
1 files changed, 11 insertions, 8 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 2f052ca..9b6bf64 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -41,6 +41,15 @@ depend()
done
}
+_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}"
+}
+
# Support bash arrays - sigh
_get_array()
{
@@ -60,10 +69,7 @@ _get_array()
esac
fi
- eval _a=\$$1
- printf "%s" "${_a}"
- printf "\n"
- [ -n "${_a}" ]
+ _array_helper $1
}
# Flatten bash arrays to simple strings
@@ -84,10 +90,7 @@ _flatten_array()
esac
fi
- eval _a=\$$1
- printf "%s" "${_a}"
- printf "\n"
- [ -n "${_a}" ]
+ _array_helper $1
}
_wait_for_carrier()