From: Roy Marples Date: Tue, 30 Oct 2018 05:52:48 +0000 (+0000) Subject: hooks: shell [ ] only supports 4 parameters X-Git-Tag: v7.1.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b680dca4ce467553acbef2a89c346049b15a219e;p=thirdparty%2Fdhcpcd.git hooks: shell [ ] only supports 4 parameters Using a fifth paramter or more is unspecified. --- diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf index b03ab578..61c75e82 100644 --- a/hooks/20-resolv.conf +++ b/hooks/20-resolv.conf @@ -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 diff --git a/hooks/29-lookup-hostname b/hooks/29-lookup-hostname index d0b10329..811c7a9c 100644 --- a/hooks/29-lookup-hostname +++ b/hooks/29-lookup-hostname @@ -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 } diff --git a/hooks/30-hostname b/hooks/30-hostname index 5f7d26da..00137c7a 100644 --- a/hooks/30-hostname +++ b/hooks/30-hostname @@ -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 diff --git a/hooks/50-ntp.conf b/hooks/50-ntp.conf index 12178684..f1736d36 100644 --- a/hooks/50-ntp.conf +++ b/hooks/50-ntp.conf @@ -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 diff --git a/hooks/50-yp.conf b/hooks/50-yp.conf index cc63d139..abe6a433 100644 --- a/hooks/50-yp.conf +++ b/hooks/50-yp.conf @@ -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" diff --git a/hooks/50-ypbind.in b/hooks/50-ypbind.in index eeb3f718..5bd5eacf 100644 --- a/hooks/50-ypbind.in +++ b/hooks/50-ypbind.in @@ -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 diff --git a/hooks/dhcpcd-run-hooks.in b/hooks/dhcpcd-run-hooks.in index 6e506dab..049bd1b5 100644 --- a/hooks/dhcpcd-run-hooks.in +++ b/hooks/dhcpcd-run-hooks.in @@ -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