From 711c46457ae9fef52c7c529d89c67d0d526f73ef Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Mon, 6 May 2013 19:20:25 +0200 Subject: Improve array handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/netctl.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/netctl.in') 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 -- cgit v1.2.3-24-g4f1b