From 82df7e4584282896a0618f14cca2dd3f3d23e8a2 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 29 Nov 2007 11:23:06 +0000 Subject: [PATCH] Use shorthand for loops --- conf.d.Linux/net.example | 2 +- init.d.Linux/modules | 2 +- init.d/netmount | 2 +- net.BSD/iwconfig.sh | 8 ++++---- net.Linux/bridge.sh | 2 +- net.Linux/iwconfig.sh | 12 ++++++------ sh/functions.sh | 4 ++-- sh/net.sh | 12 ++++++------ 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/conf.d.Linux/net.example b/conf.d.Linux/net.example index 53e71679..9cdea36d 100644 --- a/conf.d.Linux/net.example +++ b/conf.d.Linux/net.example @@ -989,7 +989,7 @@ # eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)" # eerror "in your kernel to use ip rules" # else -# for x in "$@"; do +# for x; do # ebegin "${x}" # ip rule add ${x} dev "${IFACE}" # eend $? diff --git a/init.d.Linux/modules b/init.d.Linux/modules index d2f25b67..4c21fdb5 100755 --- a/init.d.Linux/modules +++ b/init.d.Linux/modules @@ -45,7 +45,7 @@ load_modules() { eindent local x= cnt=0 - for x in "$@"; do + for x; do set -- ${x} ebegin "Loading module $1" eval modprobe -q "$@" diff --git a/init.d/netmount b/init.d/netmount index 08cdf42d..df6e0c99 100755 --- a/init.d/netmount +++ b/init.d/netmount @@ -30,7 +30,7 @@ need_portmap() { local mnt opts ret IFS=" " set -- $(fstabinfo --fstype nfs,nfs4) - for mnt in "$@"; do + for mnt; do case ,$(fstabinfo --options "${mnt}"), in *,noauto,*|*,nolock,*);; *) return 0;; diff --git a/net.BSD/iwconfig.sh b/net.BSD/iwconfig.sh index 86537767..6d670633 100644 --- a/net.BSD/iwconfig.sh +++ b/net.BSD/iwconfig.sh @@ -376,7 +376,7 @@ iwconfig_scan() { eval set -- $(_flatten_array "blacklist_aps_${IFVAR}") [ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps") - for x in "$@"; do + for x; do if [ "${x}" = "${s}" ] ; then ewarn "${s} has been blacklisted - not connecting" unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i} @@ -395,7 +395,7 @@ iwconfig_force_preferred() { ewarn "Trying to force preferred in case they are hidden" local ssid= - for ssid in "$@"; do + for ssid; do local found_AP=false i=0 e= while [ ${i} -le ${APS:--1} ] ; do eval e=\$SSID_${i} @@ -421,7 +421,7 @@ iwconfig_connect_preferred() { [ $# = 0 ] && return 1 local ssid= i=0 mode= mac= caps= freq= chan= - for ssid in "$@"; do + for ssid; do while [ ${i} -le ${APS} ] ; do eval e=\$SSID_${i} if [ "${e}" = "${ssid}" ] ; then @@ -453,7 +453,7 @@ iwconfig_connect_not_preferred() { eval set -- $(_flatten_array "preferred_aps_${IFVAR}") [ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") pref=false - for ssid in "$@"; do + for ssid; do if [ "${e}" = "${ssid}" ] ; then pref=true break diff --git a/net.Linux/bridge.sh b/net.Linux/bridge.sh index 6c3019bc..12c77768 100644 --- a/net.Linux/bridge.sh +++ b/net.Linux/bridge.sh @@ -112,7 +112,7 @@ bridge_post_stop() { # Work out if we're added to a bridge for removal or not eval set -- $(brctl show 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g") local line= - for line in "$@"; do + for line; do set -- ${line} if [ "$3" = "${IFACE}" ]; then iface=$1 diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh index 82162a41..366071e4 100644 --- a/net.Linux/iwconfig.sh +++ b/net.Linux/iwconfig.sh @@ -122,7 +122,7 @@ iwconfig_get_wep_key() { else set -- ${key} local x= e=false - for x in "$@"; do + for x; do if [ "${x}" = "enc" ]; then e=true break @@ -373,7 +373,7 @@ iwconfig_scan() { APS=-1 eval set -- ${scan} - for line in "$@"; do + for line; do case "${line}" in *Address:*) APS=$((${APS} + 1)) @@ -499,7 +499,7 @@ iwconfig_scan() { eval set -- $(_flatten_array "blacklist_aps_${IFVAR}") [ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps") - for x in "$@"; do + for x; do if [ "${x}" = "${s}" ]; then ewarn "${s} has been blacklisted - not connecting" unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i} @@ -516,7 +516,7 @@ iwconfig_force_preferred() { [ $# = 0 ] && return 1 ewarn "Trying to force preferred in case they are hidden" - for ssid in "$@"; do + for ssid; do local found_AP=false i=0 e= while [ ${i} -le ${APS} ]; do eval e=\$SSID_${i} @@ -541,7 +541,7 @@ iwconfig_connect_preferred() { eval set -- $(_flatten_array "preferred_aps_${IFVAR}") [ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") - for ssid in "$@"; do + for ssid; do unset IFS i=0 while [ ${i} -le ${APS} ]; do @@ -571,7 +571,7 @@ iwconfig_connect_not_preferred() { if [ -n "${e}" ]; then eval set -- $(_flatten_array "preferred_aps_${IFVAR}") [ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps") - for ssid in "$@"; do + for ssid; do if [ "${e}" = "${ssid}" ]; then pref=true break diff --git a/sh/functions.sh b/sh/functions.sh index 0a1ba817..fd67cb2b 100644 --- a/sh/functions.sh +++ b/sh/functions.sh @@ -78,7 +78,7 @@ is_older_than() { local x= ref="$1" shift - for x in "$@"; do + for x; do [ -e "${x}" ] || continue # We need to check the mtime if it's a directory too as the # contents may have changed. @@ -163,7 +163,7 @@ fi export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin$(_sanitize_path "${PATH}")" unset _sanitize_path -for arg in "$@"; do +for arg; do case "${arg}" in --nocolor|--nocolour|-C) export RC_NOCOLOR="yes" diff --git a/sh/net.sh b/sh/net.sh index 992eacf9..31e2bc84 100755 --- a/sh/net.sh +++ b/sh/net.sh @@ -83,7 +83,7 @@ _get_array() { case "$(declare -p "$1" 2>/dev/null)" in "declare -a "*) eval "set -- \"\${$1[@]}\"" - for _a in "$@"; do + for _a; do printf "%s\n" "${_a}" done return 0 @@ -103,7 +103,7 @@ _flatten_array() { case "$(declare -p "$1" 2>/dev/null)" in "declare -a "*) eval "set -- \"\${$1[@]}\"" - for x in "$@"; do + for x; do printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")" done return 0 @@ -165,7 +165,7 @@ _configure_variables() { for var in ${_config_vars}; do local v= - for t in "$@"; do + for t; do eval v=\$${var}_${t} if [ -n "${v}" ]; then eval ${var}_${IFVAR}=\$${var}_${t} @@ -204,7 +204,7 @@ _gen_module_list() { before() { local mod=${MODULE} local MODULE= - for MODULE in "$@"; do + for MODULE; do after "${mod}" done } @@ -315,7 +315,7 @@ _load_modules() { eval set -- \$module_${i}_program if [ -n "$1" ]; then x= - for x in "$@"; do + for x; do [ -x "${x}" ] && break done [ -x "${x}" ] || continue @@ -327,7 +327,7 @@ _load_modules() { fi if [ -n "$1" ]; then x= - for x in "$@"; do + for x; do [ -x "${x}" ] && break done [ -x "${x}" ] || continue