shell [ ] only supports 4 parameters
authorRoy Marples <roy@marples.name>
Tue, 13 Nov 2018 14:53:18 +0000 (14:53 +0000)
committerRoy Marples <roy@marples.name>
Tue, 13 Nov 2018 14:53:18 +0000 (14:53 +0000)
Using a fifth paramter or more is unspecified.

dnsmasq.in
libc.in
named.in
pdnsd.in
resolvconf.conf.5.in
resolvconf.in
unbound.in

index b1a2c7408d9c9ec05917b9a8ef3536c245617819..e0a7f530e474cdccc47bf1bea51880fb1051549b 100644 (file)
@@ -28,7 +28,7 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$dnsmasq_conf" -a -z "$dnsmasq_resolv" ] && exit 0
+[ -z "${dnsmasq_conf}${dnsmasq_resolv}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
@@ -98,7 +98,7 @@ for d in $DOMAINS; do
                                empty=false i=0
                                IFS=:
                                set -- $n
-                               while [ -n "$1" -o -n "$2" ]; do
+                               while [ -n "$1" ] || [ -n "$2" ]; do
                                        addr="$1"
                                        shift
                                        if [ -z "$addr" ]; then
@@ -184,7 +184,7 @@ if $changed; then
                eval $dnsmasq_restart
        elif [ -n "$RESTARTCMD" ]; then
                set -- ${dnsmasq_service}
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
                @SBINDIR@/resolvconf -r ${dnsmasq_service}
        fi
diff --git a/libc.in b/libc.in
index 36d84112d853ee5d57ee066141ccf69a0377837f..a1c3ed0a64e57e37f029709fedfef639a7381276 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -96,10 +96,12 @@ fi
 : ${resolv_conf:=/etc/resolv.conf}
 : ${libc_service:=nscd}
 : ${list_resolv:=@SBINDIR@/resolvconf -l}
-if [ "${resolv_conf_head-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.head ]; then
+if [ "${resolv_conf_head-x}" = x ] && [ -f "$SYSCONFDIR"/resolv.conf.head ]
+then
        resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.head)"
 fi
-if [ "${resolv_conf_tail-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.tail ]; then
+if [ "${resolv_conf_tail-x}" = x ] && [ -f "$SYSCONFDIR"/resolv.conf.tail ]
+then
        resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.tail)"
 fi
 
@@ -124,7 +126,7 @@ case "${resolv_conf_passthrough:-NO}" in
        backup=false
        newest=
        for conf in "$IFACEDIR"/*; do
-               if [ -z "$newest" -o "$conf" -nt "$newest" ]; then
+               if [ -z "$newest" ] || [ "$conf" -nt "$newest" ]; then
                        newest="$conf"
                fi
        done
@@ -176,7 +178,7 @@ case "${resolv_conf_passthrough:-NO}" in
        fi
 
        [ -n "$domain" ] && newconf="${newconf}domain $domain$NL"
-       if [ -n "$newsearch" -a "$newsearch" != "$domain" ]; then
+       if [ -n "$newsearch" ] && [ "$newsearch" != "$domain" ]; then
                newconf="${newconf}search $newsearch$NL"
        fi
        for n in $newns; do
@@ -230,7 +232,7 @@ if [ -n "$libc_restart" ]; then
        eval $libc_restart
 elif [ -n "$RESTARTCMD" ]; then
        set -- ${libc_service}
-       eval $RESTARTCMD
+       eval "$RESTARTCMD"
 else
        @SBINDIR@/resolvconf -r ${libc_service}
 fi
index 2083ea52058dba95d206fec6f08db0f780ec68a9..e5b5a91ee77a5032bcdcd0c16fff30e0110476d6 100644 (file)
--- a/named.in
+++ b/named.in
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$named_zones" -a -z "$named_options" ] && exit 0
+[ -z "${named_zones}${named_options}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
 
 # Platform specific kludges
-if [ -z "$named_service" -a -z "$named_restart" -a \
-       -d "$RCDIR" -a ! -x "$RCDIR"/named ]
+if [ -z "${named_service}${named_restart}" ] &&
+   [ -d "$RCDIR" ] && ! [ -x "$RCDIR"/named ]
 then
        if [ -x "$RCDIR"/bind9 ]; then
                # Debian and derivatives
@@ -111,7 +111,7 @@ if $changed; then
                eval $named_restart
        elif [ -n "$RESTARTCMD" ]; then
                set -- ${named_service}
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
                @SBINDIR@/resolvconf -r ${named_service}
        fi
index 6a01843dabe11dd627082e0dfc0c06051d3e9f47..971d90d26a1a491d55b4e47c5bea4e97d1c90f91 100644 (file)
--- a/pdnsd.in
+++ b/pdnsd.in
@@ -28,7 +28,7 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$pdnsd_conf" -a -z "$pdnsd_resolv" ] && exit 0
+[ -z "${pdnsd_conf}${pdnsd_resolv}" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
 NL="
 "
index fcebd864e367aea18719690dcb0f3b7cc5fb160f..c13840698bfc42308655a395ae992cb00bffc4f5 100644 (file)
@@ -70,7 +70,7 @@ These interfaces will be processed next, unless they have a metric.
 If unset, defaults to the following:-
 .D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
 .It Sy inclusive_interfaces
-Ignore any exlcusive marking for these interfaces.
+Ignore any exclusive marking for these interfaces.
 This is handy when 3rd party integrations force the
 .Nm resolvconf -x
 option and you want to disable it easily.
index b81b7a57fe561d29c98de85233a289458efe0a9e..dd8797ef47c3f2876d98bd7aa185acfeff46dff7 100644 (file)
@@ -210,7 +210,7 @@ parse_resolv()
                        ;;
                *)
                        [ -n "$line" ] && continue
-                       if [ -n "$ns" -a -n "$search" ]; then
+                       if [ -n "$ns" ] && [ -n "$search" ]; then
                                newns=
                                for n in $ns; do
                                        newns="$newns${newns:+,}$n"
@@ -296,64 +296,84 @@ detect_init()
        # systems we try to detect them first.
        status="@STATUSARG@"
        : ${status:=status}
-       if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
-               RESTARTCMD="if /bin/systemctl --quiet is-active \$1.service; then
-       /bin/systemctl restart \$1.service;
-fi"
-       elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then
-               RESTARTCMD="if /usr/bin/systemctl --quiet is-active \$1.service; then
-       /usr/bin/systemctl restart \$1.service;
-fi"
-       elif [ -x /sbin/rc-service -a \
-           -s /libexec/rc/init.d/softlevel -o -s /run/openrc/softlevel ]
+       if [ -x /bin/systemctl ] && [ -S /run/systemd/private ]; then
+               RESTARTCMD='
+                       if /bin/systemctl --quiet is-active $1.service
+                       then
+                               /bin/systemctl restart $1.service
+                       fi'
+       elif [ -x /usr/bin/systemctl ] && [ -S /run/systemd/private ]; then
+               RESTARTCMD='
+                       if /usr/bin/systemctl --quiet is-active $1.service
+                       then
+                               /usr/bin/systemctl restart $1.service
+                       fi'
+       elif [ -x /sbin/rc-service ] &&
+            { [ -s /libexec/rc/init.d/softlevel ] ||
+            [ -s /run/openrc/softlevel ]; }
        then
-               RESTARTCMD="/sbin/rc-service -i \$1 -- -Ds restart"
+               RESTARTCMD='/sbin/rc-service -i $1 -- -Ds restart'
        elif [ -x /usr/sbin/invoke-rc.d ]; then
                RCDIR=/etc/init.d
-               RESTARTCMD="if /usr/sbin/invoke-rc.d --quiet \$1 status 1>/dev/null 2>&1; then
-       /usr/sbin/invoke-rc.d \$1 restart;
-fi"
+               RESTARTCMD='
+                  if /usr/sbin/invoke-rc.d --quiet $1 status >/dev/null 2>&1
+                  then
+                       /usr/sbin/invoke-rc.d $1 restart
+                  fi'
        elif [ -x /sbin/service ]; then
                # Old RedHat
                RCDIR=/etc/init.d
-               RESTARTCMD="if /sbin/service \$1; then
-       /sbin/service \$1 restart;
-fi"
+               RESTARTCMD='
+                       if /sbin/service $1; then
+                               /sbin/service $1 restart
+                       fi'
        elif [ -x /usr/sbin/service ]; then
                # Could be FreeBSD
-               RESTARTCMD="if /usr/sbin/service \$1 $status 1>/dev/null 2>&1; then
-       /usr/sbin/service \$1 restart;
-fi"
+               RESTARTCMD="
+                       if /usr/sbin/service \$1 $status >/dev/null 2>&1
+                       then
+                               /usr/sbin/service \$1 restart
+                       fi"
        elif [ -x /bin/sv ]; then
-               RESTARTCMD="/bin/sv status \$1 >/dev/null 2>&1 && /bin/sv try-restart \$1"
+               RESTARTCMD='/bin/sv status $1 >/dev/null 2>&1 &&
+                           /bin/sv try-restart $1'
        elif [ -x /usr/bin/sv ]; then
-               RESTARTCMD="/usr/bin/sv status \$1 >/dev/null 2>&1 && /usr/bin/sv try-restart \$1"
-       elif [ -e /etc/arch-release -a -d /etc/rc.d ]; then
+               RESTARTCMD='/usr/bin/sv status $1 >/dev/null 2>&1 &&
+                           /usr/bin/sv try-restart $1'
+       elif [ -e /etc/arch-release ] && [ -d /etc/rc.d ]; then
                RCDIR=/etc/rc.d
-               RESTARTCMD="if [ -e /var/run/daemons/\$1 ]; then
-       /etc/rc.d/\$1 restart;
-fi"
-       elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
-               RESTARTCMD="if /etc/rc.d/rc.\$1 status 1>/dev/null 2>&1; then
-       /etc/rc.d/rc.\$1 restart;
-fi"
-       elif [ -e /etc/rc.d/rc.subr -a -d /etc/rc.d ]; then
+               RESTARTCMD='
+                       if [ -e /var/run/daemons/$1 ]
+                       then
+                               /etc/rc.d/$1 restart
+                       fi'
+       elif [ -e /etc/slackware-version ] && [ -d /etc/rc.d ]; then
+               RESTARTCMD='
+                       if /etc/rc.d/rc.$1 status >/dev/null 2>&1
+                       then
+                               /etc/rc.d/rc.$1 restart
+                       fi'
+       elif [ -e /etc/rc.d/rc.subr ] && [ -d /etc/rc.d ]; then
                # OpenBSD
-               RESTARTCMD="if /etc/rc.d/\$1 check 1>/dev/null 2>&1; then
-       /etc/rc.d/\$1 restart;
-fi"
+               RESTARTCMD='
+                       if /etc/rc.d/$1 check >/dev/null 2>&1
+                       then
+                               /etc/rc.d/$1 restart
+                       fi'
        else
                for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
                        [ -d $x ] || continue
-                       RESTARTCMD="if $x/\$1 $status 1>/dev/null 2>&1; then
-       $x/\$1 restart;
-fi"
+                       RESTARTCMD="
+                               if $x/\$1 $status >/dev/null 2>&1
+                               then
+                                       $x/\$1 restart
+                               fi"
                        break
                done
        fi
 
        if [ -z "$RESTARTCMD" ]; then
-               if [ "$NOINIT_WARNED" != true ]; then
+               if [ "$_NOINIT_WARNED" != true ]; then
                        warn "could not detect a useable init system"
                        _NOINIT_WARNED=true
                fi
@@ -367,7 +387,7 @@ echo_resolv()
 {
        OIFS="$IFS"
 
-       [ -n "$1" -a -f "$IFACEDIR/$1" ] || return 1
+       [ -n "$1" ] && [ -f "$IFACEDIR/$1" ] || return 1
        echo "# resolv.conf from $1"
        # Our variable maker works of the fact each resolv.conf per interface
        # is separated by blank lines.
@@ -408,7 +428,7 @@ list_resolv()
                fi
                cd "$IFACEDIR"
                for i in $inclusive_interfaces; do
-                       if [ -f "$i" -a "$list" = "$i" ]; then
+                       if [ -f "$i" ] && [ "$list" = "$i" ]; then
                                list=
                                excl=false
                                break
@@ -431,11 +451,12 @@ list_resolv()
                        done
                done
                for i in $dynamic_order; do
-                       if [ -e "$i" -a ! -e "$METRICDIR/"*" $i" ]; then
+                       if [ -e "$i" ] && ! [ -e "$METRICDIR/"*" $i" ]; then
                                list="$list $i"
                        fi
                        for ii in "$i":* "$i".*; do
-                               if [ -f "$ii" -a ! -e "$METRICDIR/"*" $ii" ]; then
+                               if [ -f "$ii" ] && ! [ -e "$METRICDIR/"*" $ii" ]
+                               then
                                        list="$list $ii"
                                fi
                        done
@@ -461,14 +482,14 @@ list_resolv()
                        continue
                fi
                
-               if [ "$cmd" = i -o "$cmd" = "-i" ]; then
+               if [ "$cmd" = i ] || [ "$cmd" = "-i" ]; then
                        printf %s "$i "
                else
                        echo_resolv "$i" && echo
                fi
-               [ $? = 0 -a "$retval" = 1 ] && retval=0
+               [ $? = 0 ] && [ "$retval" = 1 ] && retval=0
        done
-       [ "$cmd" = i -o "$cmd" = "-i" ] && echo
+       [ "$cmd" = i ] || [ "$cmd" = "-i" ] && echo
        return $retval
 }
 
@@ -572,7 +593,7 @@ make_vars()
        NAMESERVERS=
        LOCALNAMESERVERS=
        
-       if [ -n "$name_servers" -o -n "$search_domains" ]; then
+       if [ -n "${name_servers}${search_domains}" ]; then
                eval "$(echo_prepend | parse_resolv)"
        fi
        if [ -z "$VFLAG" ]; then
@@ -580,7 +601,7 @@ make_vars()
                list_resolv -i "$@" >/dev/null || IF_EXCLUSIVE=0
                eval "$(list_resolv -l "$@" | replace | parse_resolv)"
        fi
-       if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
+       if [ -n "${name_servers_append}${search_domains_append}" ]; then
                eval "$(echo_append | parse_resolv)"
        fi
 
@@ -665,36 +686,37 @@ if [ "$cmd" = D ]; then
 fi
 
 # -l lists our resolv files, optionally for a specific interface
-if [ "$cmd" = l -o "$cmd" = i ]; then
+if [ "$cmd" = l ] || [ "$cmd" = i ]; then
        list_resolv "$cmd" "$args"
        exit $?
 fi
 
 # Restart a service or echo the command to restart a service
-if [ "$cmd" = r -o "$cmd" = R ]; then
+if [ "$cmd" = r ] || [ "$cmd" = R ]; then
        detect_init || exit 1
        if [ "$cmd" = r ]; then
                set -- $args
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
-               echo "$RESTARTCMD"
+               echo "$RESTARTCMD" |
+                       sed -e '/^$/d' -e 's/^                  //g'
        fi
        exit $?
 fi
 
 # Not normally needed, but subscribers should be able to run independently
-if [ "$cmd" = v -o -n "$VFLAG" ]; then
+if [ "$cmd" = v ] || [ -n "$VFLAG" ]; then
        make_vars "$iface"
        exit $?
 fi
 
 # Test that we have valid options
-if [ "$cmd" = a -o "$cmd" = d ]; then
+if [ "$cmd" = a ] || [ "$cmd" = d ]; then
        if [ -z "$iface" ]; then
                usage "Interface not specified"
        fi
 elif [ "$cmd" != u ]; then
-       [ -n "$cmd" -a "$cmd" != h ] && usage "Unknown option $cmd"
+       [ -n "$cmd" ] && [ "$cmd" != h ] && usage "Unknown option $cmd"
        usage
 fi
 
@@ -710,7 +732,7 @@ if [ "$cmd" = a ]; then
                        "$x not allowed at start of interface name";;
                esac
        done
-       [ "$cmd" = a -a -t 0 ] && error_exit "No file given via stdin"
+       [ "$cmd" = a ] && [ -t 0 ] && error_exit "No file given via stdin"
 fi
 
 if [ ! -d "$VARDIR" ]; then
@@ -806,8 +828,8 @@ a)
                newmetric="$METRICDIR/$IF_METRIC $iface"
        fi
        rm -f "$METRICDIR/"*" $iface"
-       [ "$oldmetric" != "$newmetric" -a \
-           "$oldmetric" != "$METRICDIR/* $iface" ] &&
+       [ "$oldmetric" != "$newmetric" ] &&
+           "$oldmetric" != "$METRICDIR/* $iface" ] &&
                changed=true
        [ -n "$newmetric" ] && echo " " >"$newmetric"
 
index 46d45246ff2e598bce7f37482c3e36188c66b70f..34cb401f57c114f9044ddf79937550d6fbfda51c 100644 (file)
@@ -76,7 +76,7 @@ restart_unbound()
                eval $unbound_restart
        elif [ -n "$RESTARTCMD" ]; then
                set -- ${unbound_service}
-               eval $RESTARTCMD
+               eval "$RESTARTCMD"
        else
                @SBINDIR@/resolvconf -r ${unbound_service}
        fi