summaryrefslogtreecommitdiffstats
path: root/src/netctl.in
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-05-06 19:20:25 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2013-05-06 19:20:25 +0200
commit711c46457ae9fef52c7c529d89c67d0d526f73ef (patch)
tree6dd72940136b91807c4fb2c20e1070cc0b6584d5 /src/netctl.in
parent2587acda28156f50149a15cad67d0c0bc1eb0bb4 (diff)
downloadnetctl-711c46457ae9fef52c7c529d89c67d0d526f73ef.tar.gz
netctl-711c46457ae9fef52c7c529d89c67d0d526f73ef.tar.xz
Improve array handling
When interpreted as an array, the empty string represents a 1-element array consisting of the empty string. This is actually very reasonable. Reported by: Thomas Bächler <thomas@archlinux.org>
Diffstat (limited to 'src/netctl.in')
-rw-r--r--src/netctl.in5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/netctl.in b/src/netctl.in
index 2d04d28..e9325e3 100644
--- a/src/netctl.in
+++ b/src/netctl.in
@@ -109,14 +109,15 @@ unit_enable() {
echo ".include @systemdsystemunitdir@/netctl@.service" > "$unit"
echo -e "\n[Unit]" >> "$unit"
[[ -n $Description ]] && echo "Description=$Description" >> "$unit"
- if [[ -n ${BindsToInterfaces=$Interface} ]]; then
+ [[ -v BindsToInterfaces ]] || BindsToInterfaces=$Interface
+ if (( ${#BindsToInterfaces[@]} )); then
: ${InterfaceRoot=sys/subsystem/net/devices/}
printf "BindsTo=$(sd_escape "$InterfaceRoot")%s.device\n" \
$(sd_escape "${BindsToInterfaces[@]}") >> "$unit"
printf "After=$(sd_escape "$InterfaceRoot")%s.device\n" \
$(sd_escape "${BindsToInterfaces[@]}") >> "$unit"
fi
- if [[ -n $After ]]; then
+ if (( ${#After[@]} )); then
printf 'After="netctl@%s.service"\n' \
$(sd_escape "${After[@]}") >> "$unit"
fi