We should use lower case for normal variables. openresolv-3.1
authorRoy Marples <roy@marples.name>
Wed, 18 Mar 2009 20:56:56 +0000 (20:56 +0000)
committerRoy Marples <roy@marples.name>
Wed, 18 Mar 2009 20:56:56 +0000 (20:56 +0000)
dnsmasq.in
libc.in
named.in
resolvconf.in

index bac90e1f721f51e491cdadc75ea6a6a43e26b718..21450f30886b2a0d59b35b3d88aab0ed7ee8e76b 100644 (file)
 eval "$(${RESOLVCONF:-resolvconf} -v)"
 
 PREFIX=@PREFIX@
-DNSMASQPID="${dnsmasq_pid:-/var/run/dnsmasq.pid}"
+dnsmasqpid="${dnsmasq_pid:-/var/run/dnsmasq.pid}"
 
-NEWCONF="# Generated by resolvconf\n"
-NEWRESOLV="${NEWCONF}"
+newconf="# Generated by resolvconf\n"
+newresolv="${newconf}"
 
-# Using DBUS means that we never have to restart the daemon
+# Using dbus means that we never have to restart the daemon
 # This is important as it means we should not drop DNS queries
-# whilst changing DNS options around. However, DBUS support is optional
+# whilst changing DNS options around. However, dbus support is optional
 # so we need to validate a few things first.
 # Check for DBus support in the binary
 
-DBUS=no
-DBUSPID="${dbus_pid:-/var/run/dbus/dbus.pid}"
-[ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus.pid
-[ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus/pid
-if [ -s "${DBUSPID}" -a -s ${DNSMASQPID} ]; then
+dbus=false
+dbuspid="${dbus_pid:-/var/run/dbus/dbus.pid}"
+[ -s "${dbuspid}" ] || dbuspid=/var/run/dbus.pid
+[ -s "${dbuspid}" ] || dbuspid=/var/run/dbus/pid
+if [ -s "${dbuspid}" -a -s ${dnsmasqpid} ]; then
        if dnsmasq --version 2>/dev/null | \
                grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]"
        then
                # Sanity - check that dnsmasq and dbus are running
-               if kill -0 $(cat "${DBUSPID}") 2>/dev/null && \
-                       kill -0 $(cat ${DNSMASQPID}) 2>/dev/null
+               if kill -0 $(cat "${dbuspid}") 2>/dev/null && \
+                       kill -0 $(cat ${dnsmasqpid}) 2>/dev/null
                then
-                       DBUS=yes
-                       NEWCONF="${NEWCONF}\n# Domain specific servers will"
-                       NEWCONF="${NEWCONF} be sent over dbus\nenable-dbus\n"
+                       dbus=true
+                       newconf="${newconf}\n# Domain specific servers will"
+                       newconf="${newconf} be sent over dbus\nenable-dbus\n"
                fi
        fi
 fi
 
-for N in ${NAMESERVERS}; do
-       case "\n${NEWRESOLV}\n" in
-       *"\nnameserver ${N}\n");;
-       *) NEWRESOLV="${NEWRESOLV}nameserver ${N}\n";;
+for n in ${NAMESERVERS}; do
+       case "\n${newresolv}\n" in
+       *"\nnameserver ${n}\n");;
+       *) newresolv="${newresolv}nameserver ${n}\n";;
        esac
 done
 
-DBUSDEST=
-for D in ${DOMAINS}; do
-       DN="${D%%:*}"
-       NS="${D#*:}"
-       while [ -n "${NS}" ]; do
-               if [ "${DBUS}" = "yes" ]; then
+dbusdest=
+for d in ${DOMAINS}; do
+       dn="${d%%:*}"
+       ns="${d#*:}"
+       while [ -n "${ns}" ]; do
+               if ${dbus}; then
                        SIFS=${IFS-y} OIFS=$IFS
                        IFS=.
-                       set -- ${NS%%,*}
-                       NUM="0x$(printf "%02x" $1 $2 $3 $4)"
+                       set -- ${ns%%,*}
+                       num="0x$(printf "%02x" $1 $2 $3 $4)"
                        if [ "${SIFS}" = "y" ]; then
                                unset IFS
                        else
                                IFS=$OIFS
                        fi
-                       DBUSDEST="${DBUSDEST} uint32:$(printf "%u" ${NUM})"
-                       DBUSDEST="${DBUSDEST} string:${DN}"
+                       dbusdest="${dbusdest} uint32:$(printf "%u" ${num})"
+                       dbusdest="${dbusdest} string:${dn}"
                else
-                       NEWCONF="${NEWCONF}server=/${DN}/${NS%%,*}\n"
+                       newconf="${newconf}server=/${db}/${ns%%,*}\n"
                fi
-               [ "${NS}" = "${NS#*,}" ] && break
-               NS="${NS#*,}"
+               [ "${ns}" = "${ns#*,}" ] && break
+               ns="${ns#*,}"
        done
 done
 
-RELOAD="no"
+changed=false
 if [ -f "${dnsmasq_conf}" ]; then
-       if [ "$(cat "${dnsmasq_conf}")" != "$(printf "${NEWCONF}")" ]; then
-               RELOAD="yes"
-               printf "${NEWCONF}" > "${dnsmasq_conf}"
+       if [ "$(cat "${dnsmasq_conf}")" != "$(printf "${newconf}")" ]; then
+               changes=true
+               printf "${newconf}" > "${dnsmasq_conf}"
        fi
 else
-       RELOAD="yes"
-       printf "${NEWCONF}" > "${dnsmasq_conf}"
+       changed=true
+       printf "${newconf}" > "${dnsmasq_conf}"
 fi
 if [ -f "${dnsmasq_resolv}" ]; then
-       if [ "$(cat "${dnsmasq_resolv}")" != "$(printf "${NEWRESOLV}")" ]; then
-               RELOAD="yes"
-               printf "${NEWRESOLV}" > "${dnsmasq_resolv}"
+       if [ "$(cat "${dnsmasq_resolv}")" != "$(printf "${newresolv}")" ]; then
+               changed=true
+               printf "${newresolv}" > "${dnsmasq_resolv}"
        fi
 else
-       # dnsmasq polls this file so no need to set RELOAD="yes"
-       printf "${NEWRESOLV}" > "${dnsmasq_resolv}"
+       # dnsmasq polls this file so no need to set changed=true
+       printf "${newresolv}" > "${dnsmasq_resolv}"
 fi
 
-[ "${RELOAD}" = "yes" ] && resolvconf -s dnsmasq restart
-if [ "${DBUS}" = "yes" ]; then
-       [ "${RELOAD}" != "yes" ] && kill -HUP $(cat ${DNSMASQPID})
+${changed} && resolvconf -s dnsmasq restart
+if ${dbus}; then
+       ${restart} || kill -HUP $(cat ${dnsmasqpid})
        # Send even if empty so old servers are cleared
        dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
                /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \
-               ${DBUSDEST}
+               ${dbusdest}
 fi
diff --git a/libc.in b/libc.in
index aea4af211cc3d6e95817982efe68ab366ddff548..efa8d940a483450cc883079852a5227ca658453e 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -61,14 +61,14 @@ if [ -f "${SYSCONFDIR}"/resolvconf.conf ]; then
        . "${SYSCONFDIR}"/resolvconf.conf
 elif [ -d "${SYSCONFDIR}/resolvconf" ]; then
        SYSCONFDIR="${SYSCONFDIR}/resolvconf/resolv.conf.d"
-       BASE="${SYSCONFDIR}/resolv.conf.d/base"
+       base="${SYSCONFDIR}/resolv.conf.d/base"
        if [ -f "${BASE}" ]; then
-               name_servers="$(key_get_value "nameserver " "${BASE}")"
-               search_domains="$(key_get_value "search " "${BASE}")"
+               name_servers="$(key_get_value "nameserver " "${base}")"
+               search_domains="$(key_get_value "search " "${base}")"
                if [ -z "${search_domains}" ]; then
-                       search_domains="$(key_get_value "domain " "${BASE}")"
+                       search_domains="$(key_get_value "domain " "${base}")"
                fi
-               resolv_conf_options="$(key_get_value "options " "${BASE}")"
+               resolv_conf_options="$(key_get_value "options " "${base}")"
        fi
        if [ -f "${SYSCONFDIR}"/resolv.conf.d/head ]; then
                resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.d/head)"
@@ -77,7 +77,7 @@ elif [ -d "${SYSCONFDIR}/resolvconf" ]; then
                resolv_conf_tail="$(cat "${SYSCONFDIR}"/resolv.conf.d/tail)"
        fi
 fi
-RESOLV_CONF="${resolv_conf:-/etc/resolv.conf}"
+resolv_conf="${resolv_conf:-/etc/resolv.conf}"
 
 uniqify()
 {
@@ -92,49 +92,49 @@ done
 echo "${result# *}"
 }
 
-NEWSEARCH="$(uniqify ${search_domains} ${SEARCH})"
-NEWNS="$(uniqify ${name_servers} ${NAMESERVERS})"
+newsearch="$(uniqify ${search_domains} ${SEARCH})"
+newns="$(uniqify ${name_servers} ${NAMESERVERS})"
 
 # Hold our new resolv.conf in a variable to save on temporary files
-NEWCONF="# Generated by resolvconf\n"
+newconf="# Generated by resolvconf\n"
 if [ -n "${resolv_conf_head}" ]; then
-       NEWCONF="${NEWCONF}${resolv_conf_head}\n"
+       newconf="${newconf}${resolv_conf_head}\n"
 fi
-[ -n "${NEWSEARCH}" ] && NEWCONF="${NEWCONF}search ${NEWSEARCH}\n"
-for N in ${NEWNS}; do
-       NEWCONF="${NEWCONF}nameserver ${N}\n"
+[ -n "${newsearch}" ] && newconf="${newconf}search ${newsearch}\n"
+for n in ${newns}; do
+       newconf="${newconf}nameserver ${n}\n"
 done
 
 # Now get any configured options
-OPTS="${resolv_conf_options}${resolv_conf_options:+ }"
-OPTS="${OPTS}$(${RESOLVCONF} -l | key_get_value "options ")"
-if [ -n "${OPTS}" ]; then
-       NEWCONF="${NEWCONF}options"
-       for OPT in $(uniqify ${OPTS}); do
-               NEWCONF="${NEWCONF} ${OPT}"
+opts="${resolv_conf_options}${resolv_conf_options:+ }"
+opts="${opts}$(${RESOLVCONF} -l | key_get_value "options ")"
+if [ -n "${opts}" ]; then
+       newconf="${newconf}options"
+       for opt in $(uniqify ${opts}); do
+               newconf="${newconf} ${opt}"
        done
-       NEWCONF="${NEWCONF}\n"
+       newconf="${newconf}\n"
 fi
 
 if [ -n "{resolv_conf_tail}" ]; then
-       NEWCONF="${NEWCONF}${resolv_conf_tail}\n"
+       newconf="${newconf}${resolv_conf_tail}\n"
 fi
 
 # Check if the file has actually changed or not
-if [ -e "${RESOLV_CONF}" ]; then
-       [ "$(cat "${RESOLV_CONF}")" = "$(printf "${NEWCONF}")" ] && exit 0
+if [ -e "${resolv_conf}" ]; then
+       [ "$(cat "${resolv_conf}")" = "$(printf "${newconf}")" ] && exit 0
 fi
 
 # Create our resolv.conf now
-(umask 022; printf "${NEWCONF}" > "${RESOLV_CONF}")
+(umask 022; printf "${newconf}" > "${resolv_conf}")
 
 resolvconf -s nscd restart
 retval=$?
 
 # Notify users of the resolver
-for x in "${LIBEXECDIR}"/libc.d/*; do
-       if [ -e "${x}" ]; then
-               "${x}" "$@"
+for script in "${LIBEXECDIR}"/libc.d/*; do
+       if [ -f "${script}" -a -x "${script}" ]; then
+               RESOLVCONF="${RESOLVCONF}" "${script}" "$@"
                retval=$((${retval} + $?))
        fi
 done
index 6e9cfa0d0d5294629ee319900c9318136fc584d6..c7b8806b3249c61c82d4eba97a223277244220b4 100644 (file)
--- a/named.in
+++ b/named.in
 [ -z "${named_zones}" -o -z "${named_options}" ] && exit 0
 eval "$("${RESOLVCONF:-resolvconf}" -v)"
 
-NEWOPTIONS="# Generated by resolvconf\n"
-NEWZONES="${NEWOPTIONS}"
-FORWARD=
-for N in ${NAMESERVERS}; do
-       case "${FORWARD}" in
-       *"\n\t${N};"*);;
-       *) FORWARD="${FORWARD}\n\t${N};";;
+newoptions="# Generated by resolvconf\n"
+newzones="${newoptions}"
+forward=
+for n in ${NAMESERVERS}; do
+       case "${forward}" in
+       *"\n\t${n};"*);;
+       *) forward="${forward}\n\t${n};";;
        esac
 done
-if [ -n "${FORWARD}" ]; then
-       NEWOPTIONS="${NEWOPTIONS}forward first;\nforwarders {${FORWARD}\n};\n"
+if [ -n "${forward}" ]; then
+       newoptions="${newoptions}forward first;\nforwarders {${forward}\n};\n"
 fi
 
-for D in ${DOMAINS}; do
-       NEWZONES="${NEWZONES}zone \"${D%%:*}\" {\n"
-       NEWZONES="${NEWZONES}\ttype forward;\n"
-       NEWZONES="${NEWZONES}\tforward first;\n\tforwarders {\n"
-       NS="${D#*:}"
-       while [ -n "${NS}" ]; do
-               NEWZONES="${NEWZONES}\t\t${NS%%,*};\n"
-               [ "${NS}" = "${NS#*,}" ] && break
-               NS="${NS#*,}"
+for d in ${DOMAINS}; do
+       newzones="${newzones}zone \"${d%%:*}\" {\n"
+       newzones="${newzones}\ttype forward;\n"
+       newzones="${newzones}\tforward first;\n\tforwarders {\n"
+       ns="${d#*:}"
+       while [ -n "${ns}" ]; do
+               newzones="${newzones}\t\t${ns%%,*};\n"
+               [ "${ns}" = "${ns#*,}" ] && break
+               ns="${ns#*,}"
        done
-       NEWZONES="${NEWZONES}\t};\n};\n"
+       newzones="${newzones}\t};\n};\n"
 done
 
 # No point in changing files or reloading bind if the end result has not
 # changed
-RELOAD="no"
+changed=false
 if [ -f "${named_options}" ]; then 
-       if [ "$(cat "${named_options}")" != "$(printf "${NEWOPTIONS}")" ]; then
-               printf "${NEWOPTIONS}" > "${named_options}"
-               RELOAD="yes"
+       if [ "$(cat "${named_options}")" != "$(printf "${newoptions}")" ]; then
+               printf "${newoptions}" > "${named_options}"
+               changed=true
        fi
 else
-       printf "${NEWOPTIONS}" > "${named_options}"
-       RELOAD="yes"
+       printf "${newoptions}" > "${named_options}"
+       changed=true
 fi
 if [ -f "${named_zones}" ]; then
-       if [ "$(cat "${named_zones}")" != "$(printf "${NEWZONES}")" ]; then
-               printf "${NEWZONES}" > "${named_zones}"
-               RELOAD="yes"
+       if [ "$(cat "${named_zones}")" != "$(printf "${newzones}")" ]; then
+               printf "${newzones}" > "${named_zones}"
+               changed=true
        fi
 else
-       printf "${NEWZONES}" > "${named_zones}"
-       RELOAD="yes"
+       printf "${newzones}" > "${named_zones}"
+       changed=true
 fi
 
-[ "${RELOAD}" = "yes" ] && resolvconf -s named restart
+${changed} && resolvconf -s named restart
 exit 0
index dc2872ca0116f08dffe369db45711ab6e98adadd..69158866ea39444e55d654661673f8cdcef1dcd3 100644 (file)
@@ -83,14 +83,14 @@ usage()
 
 echo_resolv()
 {
-       local LINE=
+       local line=
        [ -n "$1" -a -e "${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.
        # So we remove them when echoing them.
-       while read LINE; do
-               [ -n "${LINE}" ] && echo "${LINE}"
+       while read line; do
+               [ -n "${line}" ] && echo "${line}"
        done < "${IFACEDIR}/$1"
        echo
 }
@@ -99,54 +99,50 @@ echo_resolv()
 # for domain name servers, search name servers and global nameservers
 parse_resolv()
 {
-       local LINE= NS= DOMAINS= SEARCH= D= N= NEWNS=
-       local NEW=true IFACE=
+       local line= ns= domains= search= d= n= newns=
+       local new=true iface=
 
        echo "DOMAINS="
        echo "SEARCH="
        echo "NAMESERVERS="
 
-       while read LINE; do
-               case "${LINE}" in
+       while read line; do
+               case "${line}" in
                "# resolv.conf from "*)
-                       if ${NEW}; then
-                               IFACE="${LINE#\# resolv.conf from *}"
-                               NEW=false
+                       if ${new}; then
+                               iface="${line#\# resolv.conf from *}"
+                               new=false
                        fi
                        ;;
                "nameserver "*)
-                       case "${LINE#* }" in
+                       case "${line#* }" in
                        127.*) continue;;
                        esac
-                       NS="${NS}${LINE#* } "
+                       ns="${ns}${line#* } "
                        ;;
-               "domain "*)
-                       SEARCH="${LINE#* }"
-                       ;;
-               "search "*)
-                       SEARCH="${LINE#* }"
+               "domain "*|"search "*)
+                       search="${line#* }"
                        ;;
                *)
-                       if [ -z "${LINE}" ]; then
-                               if [ -n "${NS}" -a -n "${SEARCH}" ]; then
-                                       NEWNS=
-                                       for N in ${NS}; do
-                                               NEWNS="${NEWNS}${NEWNS:+,}${N}"
+                       if [ -z "${line}" ]; then
+                               if [ -n "${ns}" -a -n "${search}" ]; then
+                                       newns=
+                                       for n in ${ns}; do
+                                               newns="${newns}${newns:+,}${n}"
                                        done
-                                       DOMAINS=
-                                       for D in ${SEARCH}; do
-                                               DOMAINS="${DOMAINS}${DOMAINS:+ }${D}:${NEWNS}"
+                                       domains=
+                                       for d in ${search}; do
+                                               domains="${domains}${domains:+ }${d}:${newns}"
                                        done
-                                       echo "DOMAINS=\"\${DOMAINS} ${DOMAINS}\""
+                                       echo "DOMAINS=\"\${DOMAINS} ${domains}\""
                                fi
-                               echo "SEARCH=\"\${SEARCH} ${SEARCH}\""
-                               if [ ! -e "${PRIVATEDIR}/${IFACE}" ]; then
-                                       echo "NAMESERVERS=\"\${NAMESERVERS} ${NS}\""
+                               echo "SEARCH=\"\${SEARCH} ${search}\""
+                               if [ ! -e "${PRIVATEDIR}/${iface}" ]; then
+                                       echo "NAMESERVERS=\"\${NAMESERVERS} ${ns}\""
                                fi
-                               NS=
-                               SEARCH=
-                               PRIVATE=false
-                               NEW=true
+                               ns=
+                               search=
+                               new=true
                        fi
                        ;;
                esac
@@ -166,39 +162,39 @@ uniqify()
        echo "${result# *}"
 }
 
-FORCE=false
+force=false
 while getopts a:d:fhilm:ps:uv OPT; do
        case "${OPT}" in
-       f) FORCE=true;;
+       f) force=true;;
        h) usage;;
        m) IF_METRIC="${OPTARG}";;
        p) IF_PRIVATE=1;;
-       s) CMD=s; SERVICE="${OPTARG}";;
+       s) cmd=s; service="${OPTARG}";;
        '?') ;;
-       *) CMD="${OPT}"; IFACE="${OPTARG}";;
+       *) cmd="${OPT}"; iface="${OPTARG}";;
        esac
 done
 shift $((${OPTIND} - 1))
-ARGS="${IFACE}${IFACE:+ }$@"
+args="${iface}${iface:+ }$@"
 
 # We do our service restarting here so that our subscribers don't have to know
 # about the OS's init system.
-if [ "${CMD}" = "s" ]; then
+if [ "${cmd}" = "s" ]; then
        if [ -n "$1" ]; then
-               ACTION="$1"
+               action="$1"
                shift
        fi
-       [ -z "${ACTION}" ] && usage "Action not specified"
+       [ -z "${action}" ] && usage "Action not specified"
 
        # If restarting check if service is running or not if we can
-       if [ "${ACTION}" = "restart" ]; then
-               if [ -s /var/run/"${SERVICE}".pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}".pid) 2>/dev/null
-               elif [ -s /var/run/"${SERVICE}"/"${SERVICE}".pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}"/"${SERVICE}".pid) \
+       if [ "${action}" = "restart" ]; then
+               if [ -s /var/run/"${service}".pid ]; then
+                       kill -0 $(cat /var/run/"${service}".pid) 2>/dev/null
+               elif [ -s /var/run/"${service}"/"${service}".pid ]; then
+                       kill -0 $(cat /var/run/"${service}"/"${service}".pid) \
                                2>/dev/null
-               elif [ -s /var/run/"${SERVICE}"/pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}"/pid) 2>/dev/null
+               elif [ -s /var/run/"${service}"/pid ]; then
+                       kill -0 $(cat /var/run/"${service}"/pid) 2>/dev/null
                else
                        false
                fi
@@ -206,21 +202,21 @@ if [ "${CMD}" = "s" ]; then
                [ $? != 0 ] && exit 0
        fi      
        if [ -x /sbin/service ]; then
-               service "${SERVICE}" "${ACTION}" "$@" 
-       elif [ -x /etc/init.d/"${SERVICE}" -a -x /sbin/runscript ]; then
-               if [ "${ACTION}" = "restart" ]; then
-                       /etc/init.d/"${SERVICE}" --quiet --nodeps \
+               service "${service}" "${action}" "$@" 
+       elif [ -x /etc/init.d/"${service}" -a -x /sbin/runscript ]; then
+               if [ "${action}" = "restart" ]; then
+                       /etc/init.d/"${service}" --quiet --nodeps \
                                conditionalrestart "$@"
                else
-                       /etc/init.d/"${SERVICE}" --quiet --nodeps \
-                               "${ACTION}" "$@"
+                       /etc/init.d/"${service}" --quiet --nodeps \
+                               "${action}" "$@"
                fi
-       elif [ -x /etc/init.d/"${SERVICE}" ]; then
-               /etc/init.d/"${SERVICE}" "${ACTION}" "$@"
-       elif [ -x /etc/rc.d/"${SERVICE}" ]; then
-               /etc/rc.d/"${SERVICE}" "${ACTION}" "$@" 
-       elif [ -x /etc/rc.d/rc."${SERVICE}" ]; then
-               /etc/rc.d/rc."${SERVICE}" "${ACTION}" "$@"
+       elif [ -x /etc/init.d/"${service}" ]; then
+               /etc/init.d/"${service}" "${action}" "$@"
+       elif [ -x /etc/rc.d/"${service}" ]; then
+               /etc/rc.d/"${service}" "${action}" "$@" 
+       elif [ -x /etc/rc.d/rc."${service}" ]; then
+               /etc/rc.d/rc."${service}" "${action}" "$@"
        else
                error_exit "Don't know how to interact with services on" \
                        "this platform"
@@ -229,124 +225,124 @@ if [ "${CMD}" = "s" ]; then
 fi
 
 # -l lists our resolv files, optionally for a specific interface
-if [ "${CMD}" = "l" -o "${CMD}" = "i" ]; then
+if [ "${cmd}" = "l" -o "${cmd}" = "i" ]; then
        [ -d "${IFACEDIR}" ] || exit 0
 
-       REPORT=false
+       report=false
        # If we have an interface ordering list, then use that.
        # It works by just using pathname expansion in the interface directory.
-       if [ -n "${ARGS}" ]; then
-               LIST="${ARGS}"
-               ${FORCE} || REPORT=true
+       if [ -n "${args}" ]; then
+               list="${args}"
+               ${force} || report=true
        else
                cd "${IFACEDIR}"
-               for LST in ${interface_order}; do
-                       [ -e "${LST}" ] && LIST="${LIST} ${LST}"
+               for i in ${interface_order}; do
+                       [ -e "${i}" ] && list="${list} ${i}"
                done
-               for DYN in ${dynamic_order}; do
-                       if [ -e "${DYN}" -a ! -e "${METRICDIR}/"*" ${DYN}" ]
-                       then
-                               LIST="${LIST} ${DYN}"
+               for i in ${dynamic_order}; do
+                       if [ -e "${i}" -a ! -e "${METRICDIR}/"*" ${i}" ]; then
+                               list="${list} ${i}"
                        fi
                done
                if [ -d "${METRICDIR}" ]; then
                        cd "${METRICDIR}"
-                       for METRIC in *; do
-                               LIST="${LIST} ${METRIC#* }"
+                       for i in *; do
+                               list="${list} ${i#* }"
                        done
                fi
-               LIST="${LIST} *"
+               list="${list} *"
        fi
 
-       RETVAL=0
+       retval=0
        cd "${IFACEDIR}"
-       for IFACE in $(uniqify ${LIST}); do
+       for i in $(uniqify ${list}); do
                # Only list interfaces which we really have
-               if ! [ -e "${IFACE}" ]; then
-                       if ${REPORT}; then
-                               echo "No resolv.conf for interface" \
-                                       "${IFACE}" >&2
-                               RETVAL=$((${RETVAL} + 1))
+               if ! [ -e "${i}" ]; then
+                       if ${report}; then
+                               echo "No resolv.conf for interface ${i}" >&2
+                               retval=$((${retval} + 1))
                        fi
                        continue
                fi
                
-               if [ "${CMD}" = "i" ]; then
-                       printf "${IFACE} "
+               if [ "${cmd}" = "i" ]; then
+                       printf "${i} "
                else
-                       echo_resolv "${IFACE}"
+                       echo_resolv "${i}"
                fi
        done
-       [ "${CMD}" = "i" ] && echo
-       exit ${RETVAL
+       [ "${cmd}" = "i" ] && echo
+       exit ${retval
 fi
 
-if [ "${CMD}" = "v" ]; then
-       eval "$("${ARGV0}" -l "${IFACE}" | parse_resolv)"
+if [ "${cmd}" = "v" ]; then
+       eval "$("${ARGV0}" -l "${iface}" | parse_resolv)"
 
        # Ensure that we only list each domain once
-       NEWDOMAINS=
-       for D in ${DOMAINS}; do
-               DN="${D%%:*}"
-               case " ${NEWDOMAINS}" in
-               *" ${DN}:"*) continue;;
+       newdomains=
+       for d in ${DOMAINS}; do
+               dn="${d%%:*}"
+               case " ${newdomains}" in
+               *" ${dn}:"*) continue;;
                esac
-               DONE="${DONE} ${DN}"
-               NEWDOMAINS="${NEWDOMAINS}${NEWDOMAINS:+ }${DN}:"
-               NEWNS=
-               for ND in ${DOMAINS}; do
-                       if [ "${DN}" = "${ND%%:*}" ]; then
-                               NS="${ND#*:}"
-                               while [ -n "${NS}" ]; do
-                                       NEWNS="${NEWNS}${NEWNS:+,}${NS%%,*}"
-                                       [ "${NS}" = "${NS#*,}" ] && break
-                                       NS="${NS#*,}"
+               newdomains="${newdomains}${newdomains:+ }${dn}:"
+               newns=
+               for nd in ${DOMAINS}; do
+                       if [ "${dn}" = "${nd%%:*}" ]; then
+                               ns="${nd#*:}"
+                               while [ -n "${ns}" ]; do
+                                       case ",${newns}," in
+                                       *,${ns%%,*},*) ;;
+                                       *) newns="${newns}${newns:+,}${ns%%,*}"
+                                               ;;
+                                       esac
+                                       [ "${ns}" = "${ns#*,}" ] && break
+                                       ns="${ns#*,}"
                                done
                        fi
                done
-               NEWDOMAINS="${NEWDOMAINS}${NEWNS}"
+               newdomains="${newdomains}${newns}"
        done
-       echo "DOMAINS='${NEWDOMAINS}'"
+       echo "DOMAINS='${newdomains}'"
        echo "SEARCH='$(uniqify ${SEARCH})'"
        echo "NAMESERVERS='$(uniqify ${NAMESERVERS})'"
        exit 0
 fi
 
 # Test that we have valid options
-if [ "${CMD}" = "a" -o "${CMD}" = "d" ]; then
-       if [ -z "${IFACE}" ]; then
+if [ "${cmd}" = "a" -o "${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}"
+elif [ "${cmd}" != "u" ]; then
+       [ -n "${cmd}" -a "${cmd}" != "h" ] && usage "Unknown option ${cmd}"
        usage
 fi
-if [ "${CMD}" = "a" ]; then
+if [ "${cmd}" = "a" ]; then
        for x in '/' \\ ' ' '*'; do
-               case "${IFACE}" in
+               case "${iface}" in
                *[${x}]*) error_exit "${x} not allowed in interface name";;
                esac
        done
        for x in '.' '-' '~'; do
-               case "${IFACE}" in
+               case "${iface}" in
                [${x}]*) error_exit \
                        "${x} not allowed at start of interface name";;
                esac
        done
-       [ "${CMD}" = "a" -a -t 0 ] && error_exit "No file given via stdin"
-       IFACERESOLV="${IFACEDIR}/${IFACE}"
+       [ "${cmd}" = "a" -a -t 0 ] && error_exit "No file given via stdin"
 fi
 
 # Ensure that libdir exists
 if [ ! -d "${IFACEDIR}" ]; then
        if [ ! -d "${VARDIR}" ]; then
                if [ -L "${VARDIR}" ]; then
-                       DIR="$(readlink "${VARDIR}")"
-                       # Change to /etc as link maybe relative
+                       dir="$(readlink "${VARDIR}")"
+                       # link maybe relative
                        cd "${VARDIR%/*}"
-                       if ! mkdir -m 0755 -p "${DIR}"; then
+                       if ! mkdir -m 0755 -p "${dir}"; then
                                error_exit "Failed to create needed" \
-                                       "directory ${DIR}"
+                                       "directory ${dir}"
                        fi
                else
                        if ! mkdir -m 0755 -p "${VARDIR}"; then
@@ -359,41 +355,41 @@ if [ ! -d "${IFACEDIR}" ]; then
                error_exit "Failed to create needed directory ${IFACEDIR}"
 else
        # Delete any existing information about the interface
-       if [ "${CMD}" = "d" ]; then
+       if [ "${cmd}" = "d" ]; then
                cd "${IFACEDIR}"
-               for ARG in ${ARGS}; do
-                       if [ "${CMD}" = "d" -a ! -e "${ARG}" ]; then
-                               ${FORCE} && continue
+               for i in ${args}; do
+                       if [ "${cmd}" = "d" -a ! -e "${i}" ]; then
+                               ${force} && continue
                                error_exit "No resolv.conf for" \
-                                       "interface ${ARG}"
+                                       "interface ${i}"
                        fi
-                       rm -f "${ARG}" "${METRICDIR}/"*" ${ARG}" \
-                               "${PRIVATEDIR}/${ARG}" || exit $?
+                       rm -f "${i}" "${METRICDIR}/"*" ${i}" \
+                               "${PRIVATEDIR}/${i}" || exit $?
                done
        fi
 fi
 
-if [ "${CMD}" = "a" ]; then
+if [ "${cmd}" = "a" ]; then
        # Read resolv.conf from stdin
-       RESOLV="$(cat)\n"
+       resolv="$(cat)\n"
        # If what we are given matches what we have, then do nothing
-       if [ -e "${IFACEDIR}/${IFACE}" ]; then
-               if [ "$(printf "${RESOLV}")" = \
-                       "$(cat "${IFACEDIR}/${IFACE}")" ]
+       if [ -e "${IFACEDIR}/${iface}" ]; then
+               if [ "$(printf "${resolv}")" = \
+                       "$(cat "${IFACEDIR}/${iface}")" ]
                then
                        exit 0
                fi
-               rm "${IFACEDIR}/${IFACE}"
+               rm "${IFACEDIR}/${iface}"
        fi
-       printf "${RESOLV}" >"${IFACEDIR}/${IFACE}" || exit $?
+       printf "${resolv}" >"${IFACEDIR}/${iface}" || exit $?
        [ ! -d "${METRICDIR}" ] && mkdir "${METRICDIR}"
-       rm -f "${METRICDIR}/"*" ${IFACE}"
+       rm -f "${METRICDIR}/"*" ${iface}"
        if [ -n "${IF_METRIC}" ]; then
                # Pad metric to 6 characters, so 5 is less than 10
                while [ ${#IF_METRIC} -le 6 ]; do
                        IF_METRIC="0${IF_METRIC}"
                done
-               echo " " >"${METRICDIR}/${IF_METRIC} ${IFACE}"
+               echo " " >"${METRICDIR}/${IF_METRIC} ${iface}"
        fi
        case "${IF_PRIVATE}" in
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
@@ -401,20 +397,20 @@ if [ "${CMD}" = "a" ]; then
                        [ -e "${PRIVATEDIR}" ] && rm "${PRIVATEDIR}"
                        mkdir "${PRIVATEDIR}"
                fi
-               [ -d "${PRIVATEDIR}" ] && echo " " >"${PRIVATEDIR}/${IFACE}"
+               [ -d "${PRIVATEDIR}" ] && echo " " >"${PRIVATEDIR}/${iface}"
                ;;
        *)
-               if [ -e "${PRIVATEDIR}/${IFACE}" ]; then
-                       rm -f "${PRIVATEDIR}/${IFACE}"
+               if [ -e "${PRIVATEDIR}/${iface}" ]; then
+                       rm -f "${PRIVATEDIR}/${iface}"
                fi
                ;;
        esac
 fi
 
-RETVAL=0
-for SCRIPT in "${LIBEXECDIR}"/*; do
-       [ -f "${SCRIPT}" -a -x "${SCRIPT}" ] || continue
-       RESOLVCONF="${ARGV0}" "${SCRIPT}" "${CMD}" "${IFACE}"
-       RETVAL=$((${RETVAL} + $?))
+retval=0
+for script in "${LIBEXECDIR}"/*; do
+       [ -f "${script}" -a -x "${script}" ] || continue
+       RESOLVCONF="${ARGV0}" "${script}" "${cmd}" "${iface}"
+       retval=$((${retval} + $?))
 done
-exit ${RETVAL}
+exit ${retval}