]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
hooks: shell [ ] only supports 4 parameters
authorRoy Marples <roy@marples.name>
Tue, 30 Oct 2018 05:52:48 +0000 (05:52 +0000)
committerRoy Marples <roy@marples.name>
Tue, 30 Oct 2018 05:52:48 +0000 (05:52 +0000)
Using a fifth paramter or more is unspecified.

hooks/20-resolv.conf
hooks/29-lookup-hostname
hooks/30-hostname
hooks/50-ntp.conf
hooks/50-yp.conf
hooks/50-ypbind.in
hooks/dhcpcd-run-hooks.in

index b03ab5789f52a5b1702e5cf872934e6012b052d3..61c75e82141c9cabf58e355fe4549c064d2b33d8 100644 (file)
@@ -77,19 +77,19 @@ build_resolv_conf()
 eval_nd_dns()
 {
        eval ltime=\$nd${i}_rdnss${j}_lifetime
-       if [ -z "$ltime" -o "$ltime" = 0 ]; then
+       if [ -z "$ltime" ] || [ "$ltime" = 0 ]; then
                rdnss=
        else
                eval rdnss=\$nd${i}_rdnss${j}_servers
        fi
        eval ltime=\$nd${i}_dnssl${j}_lifetime
-       if [ -z "$ltime" -o "$ltime" = 0 ]; then
+       if [ -z "$ltime" ] || [ "$ltime" = 0 ]; then
                dnssl=
        else
                eval dnssl=\$nd${i}_dnssl${j}_search
        fi
 
-       [ -z "$rdnss" -a -z "$dnssl" ] && return 1
+       [ -z "${rdnss}${dnssl}" ] && return 1
 
        [ -n "$rdnss" ] && new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
        [ -n "$dnssl" ] && new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
@@ -130,9 +130,9 @@ add_resolv_conf()
        fi
 
        # If we don't have any configuration, remove it
-       if [ -z "$new_domain_name_servers" -a \
-               -z "$new_domain_name" -a \
-               -z "$new_domain_search" ]; then
+       if [ -z "$new_domain_name_servers" ] &&
+          [ -z "$new_domain_name" ] &&
+          [ -z "$new_domain_search" ]; then
                remove_resolv_conf
                return $?
        fi
index d0b10329cf69e4a858d4f48f39dc2baf2b3cac51..811c7a9c89bf1999570262ac7f5cf2387a4d4770 100644 (file)
@@ -29,7 +29,7 @@ lookup_hostname()
 
 set_hostname()
 {
-       if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
+       if [ -z "${new_host_name}${new_fqdn_name}" ]; then
                export new_host_name="$(lookup_hostname)"
        fi
 }
index 5f7d26da16cbd065318fb3cbd99801fd6282a29a..00137c7a54b1010ee4eaa1dce3ac8c78b178b9a8 100644 (file)
@@ -87,8 +87,8 @@ need_hostname()
                fi
        elif [ -n "$old_host_name" ]; then
                if ${hfqdn}; then
-                       if [ -n "$old_domain_name" -a \
-                           "$old_host_name" = "${old_host_name#*.}" ]
+                       if [ -n "$old_domain_name" ] &&
+                          [ "$old_host_name" = "${old_host_name#*.}" ]
                        then
                                [ "$hostname" = \
                                    "$old_host_name.$old_domain_name" ]
@@ -131,8 +131,8 @@ set_hostname()
                fi
        elif [ -n "$new_host_name" ]; then
                if ${hfqdn}; then
-                       if [ -n "$new_domain_name" -a \
-                           "$new_host_name" = "${new_host_name#*.}" ]
+                       if [ -n "$new_domain_name" ] &&
+                          [ "$new_host_name" = "${new_host_name#*.}" ]
                        then
                                try_hostname "$new_host_name.$new_domain_name"
                        else
index 1217868486eb7379bbaaef5e9d0f150f5d576eaa..f1736d362f0d22dbe4bd3ffb66c7c34faa120725 100644 (file)
@@ -96,7 +96,7 @@ build_ntp_conf()
                printf %s "$servers" >> "$cf"
                echo "$signature_base_end${header:+ $from }$header" >> "$cf"
        else
-               [ -e "$ntp_conf" -a -e "$cf" ] || return
+               [ -e "$ntp_conf" ] && [ -e "$cf" ] || return
        fi
 
        # If we changed anything, restart ntpd
index cc63d139221ff84240aa8238034cb713b9d301ba..abe6a4334eebed20f2380cb068cfa2bd8bb990b2 100644 (file)
@@ -8,7 +8,7 @@ ypbind_pid()
 
 make_yp_conf()
 {
-       [ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0
+       [ -z "${new_nis_domain}${new_nis_servers}" ] && return 0
        cf=/etc/yp.conf."$ifname"
        rm -f "$cf"
        echo "$signature" > "$cf"
index eeb3f7184577fef7268c89b947797ad0cb9d90e2..5bd5eacf9e41d28e76015c638807fd7b3c095e81 100644 (file)
@@ -41,7 +41,7 @@ make_yp_binding()
        fi
 
        nd="$(best_domain)"
-       if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
+       if [ $? = 0 ] && [ "$nd" != "$(domainname)" ]; then
                domainname "$nd"
                if [ -n "$ypbind_restart_cmd" ]; then
                        eval $ypbind_restart_cmd
index 6e506dab997ab4b39ddc6e71c6be856774e27c7e..049bd1b542a81baebec72cb510b8bc89cc084dfd 100644 (file)
@@ -107,7 +107,7 @@ remove_markers()
 # Compare two files.
 comp_file()
 {
-       [ -e "$1" -a -e "$2" ] || return 1
+       [ -e "$1" ] && [ -e "$2" ] || return 1
 
        if type cmp >/dev/null 2>&1; then
                cmp -s "$1" "$2"
@@ -187,11 +187,11 @@ syslog()
 valid_domainname()
 {
        name="$1"
-       [ -z "$name" -o ${#name} -gt 255 ] && return 1
+       [ -z "$name" ] || [ ${#name} -gt 255 ] && return 1
        
        while [ -n "$name" ]; do
                label="${name%%.*}"
-               [ -z "$label" -o ${#label} -gt 63 ] && return 1
+               [ -z "$label" ] || [ ${#label} -gt 63 ] && return 1
                case "$label" in
                -*|_*|*-|*_)            return 1;;
                *[![:alnum:]_-]*)       return 1;;
@@ -231,16 +231,17 @@ detect_init()
        # systems we try to detect them first.
        status="@STATUSARG@"
        : ${status:=status}
-       if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
+       if [ -x /bin/systemctl ] && [ -S /run/systemd/private ]; then
                _service_exists="/bin/systemctl --quiet is-enabled \$1.service"
                _service_status="/bin/systemctl --quiet is-active \$1.service"
                _service_cmd="/bin/systemctl \$2 \$1.service"
-       elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then
+       elif [ -x /usr/bin/systemctl ] && [ -S /run/systemd/private ]; then
                _service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
                _service_status="/usr/bin/systemctl --quiet is-active \$1.service"
                _service_cmd="/usr/bin/systemctl \$2 \$1.service"
-       elif [ -x /sbin/rc-service -a \
-           -s /libexec/rc/init.d/softlevel -o -s /run/openrc/softlevel ]
+       elif [ -x /sbin/rc-service ] &&
+            { [ -s /libexec/rc/init.d/softlevel ] ||
+            [ -s /run/openrc/softlevel ]; }
        then
                _service_exists="/sbin/rc-service -e \$1"
                _service_cmd="/sbin/rc-service \$1 -- -D \$2"
@@ -259,7 +260,7 @@ detect_init()
        elif [ -x /usr/bin/sv ]; then
                _service_exists="/usr/bin/sv status \$1 >/dev/null 2>&1"
                _service_cmd="/usr/bin/sv \$2 \$1"
-       elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
+       elif [ -e /etc/slackware-version ] && [ -d /etc/rc.d ]; then
                _service_exists="[ -x /etc/rc.d/rc.\$1 ]"
                _service_cmd="/etc/rc.d/rc.\$1 \$2"
                _service_status="/etc/rc.d/rc.\$1 status >/dev/null 2>&1"
@@ -274,7 +275,7 @@ detect_init()
                done
                if [ -e /etc/arch-release ]; then
                        _service_status="[ -e /var/run/daemons/\$1 ]"
-               elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then
+               elif [ "$x" = "/etc/rc.d" ] && [ -e /etc/rc.d/rc.subr ]; then
                        _service_status="$x/\$1 check >/dev/null 2>&1"
                fi
        fi