Use shorthand for loops
This commit is contained in:
parent
50161bef0e
commit
82df7e4584
@ -989,7 +989,7 @@
|
|||||||
# eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
|
# eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
|
||||||
# eerror "in your kernel to use ip rules"
|
# eerror "in your kernel to use ip rules"
|
||||||
# else
|
# else
|
||||||
# for x in "$@"; do
|
# for x; do
|
||||||
# ebegin "${x}"
|
# ebegin "${x}"
|
||||||
# ip rule add ${x} dev "${IFACE}"
|
# ip rule add ${x} dev "${IFACE}"
|
||||||
# eend $?
|
# eend $?
|
||||||
|
@ -45,7 +45,7 @@ load_modules() {
|
|||||||
eindent
|
eindent
|
||||||
|
|
||||||
local x= cnt=0
|
local x= cnt=0
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
set -- ${x}
|
set -- ${x}
|
||||||
ebegin "Loading module $1"
|
ebegin "Loading module $1"
|
||||||
eval modprobe -q "$@"
|
eval modprobe -q "$@"
|
||||||
|
@ -30,7 +30,7 @@ need_portmap() {
|
|||||||
local mnt opts ret IFS="
|
local mnt opts ret IFS="
|
||||||
"
|
"
|
||||||
set -- $(fstabinfo --fstype nfs,nfs4)
|
set -- $(fstabinfo --fstype nfs,nfs4)
|
||||||
for mnt in "$@"; do
|
for mnt; do
|
||||||
case ,$(fstabinfo --options "${mnt}"), in
|
case ,$(fstabinfo --options "${mnt}"), in
|
||||||
*,noauto,*|*,nolock,*);;
|
*,noauto,*|*,nolock,*);;
|
||||||
*) return 0;;
|
*) return 0;;
|
||||||
|
@ -376,7 +376,7 @@ iwconfig_scan() {
|
|||||||
|
|
||||||
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
|
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
|
||||||
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
|
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
if [ "${x}" = "${s}" ] ; then
|
if [ "${x}" = "${s}" ] ; then
|
||||||
ewarn "${s} has been blacklisted - not connecting"
|
ewarn "${s} has been blacklisted - not connecting"
|
||||||
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
|
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"
|
ewarn "Trying to force preferred in case they are hidden"
|
||||||
local ssid=
|
local ssid=
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
local found_AP=false i=0 e=
|
local found_AP=false i=0 e=
|
||||||
while [ ${i} -le ${APS:--1} ] ; do
|
while [ ${i} -le ${APS:--1} ] ; do
|
||||||
eval e=\$SSID_${i}
|
eval e=\$SSID_${i}
|
||||||
@ -421,7 +421,7 @@ iwconfig_connect_preferred() {
|
|||||||
[ $# = 0 ] && return 1
|
[ $# = 0 ] && return 1
|
||||||
|
|
||||||
local ssid= i=0 mode= mac= caps= freq= chan=
|
local ssid= i=0 mode= mac= caps= freq= chan=
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
while [ ${i} -le ${APS} ] ; do
|
while [ ${i} -le ${APS} ] ; do
|
||||||
eval e=\$SSID_${i}
|
eval e=\$SSID_${i}
|
||||||
if [ "${e}" = "${ssid}" ] ; then
|
if [ "${e}" = "${ssid}" ] ; then
|
||||||
@ -453,7 +453,7 @@ iwconfig_connect_not_preferred() {
|
|||||||
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
||||||
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
||||||
pref=false
|
pref=false
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
if [ "${e}" = "${ssid}" ] ; then
|
if [ "${e}" = "${ssid}" ] ; then
|
||||||
pref=true
|
pref=true
|
||||||
break
|
break
|
||||||
|
@ -112,7 +112,7 @@ bridge_post_stop() {
|
|||||||
# Work out if we're added to a bridge for removal or not
|
# 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")
|
eval set -- $(brctl show 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")
|
||||||
local line=
|
local line=
|
||||||
for line in "$@"; do
|
for line; do
|
||||||
set -- ${line}
|
set -- ${line}
|
||||||
if [ "$3" = "${IFACE}" ]; then
|
if [ "$3" = "${IFACE}" ]; then
|
||||||
iface=$1
|
iface=$1
|
||||||
|
@ -122,7 +122,7 @@ iwconfig_get_wep_key() {
|
|||||||
else
|
else
|
||||||
set -- ${key}
|
set -- ${key}
|
||||||
local x= e=false
|
local x= e=false
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
if [ "${x}" = "enc" ]; then
|
if [ "${x}" = "enc" ]; then
|
||||||
e=true
|
e=true
|
||||||
break
|
break
|
||||||
@ -373,7 +373,7 @@ iwconfig_scan() {
|
|||||||
|
|
||||||
APS=-1
|
APS=-1
|
||||||
eval set -- ${scan}
|
eval set -- ${scan}
|
||||||
for line in "$@"; do
|
for line; do
|
||||||
case "${line}" in
|
case "${line}" in
|
||||||
*Address:*)
|
*Address:*)
|
||||||
APS=$((${APS} + 1))
|
APS=$((${APS} + 1))
|
||||||
@ -499,7 +499,7 @@ iwconfig_scan() {
|
|||||||
|
|
||||||
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
|
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
|
||||||
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
|
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
if [ "${x}" = "${s}" ]; then
|
if [ "${x}" = "${s}" ]; then
|
||||||
ewarn "${s} has been blacklisted - not connecting"
|
ewarn "${s} has been blacklisted - not connecting"
|
||||||
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
|
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
|
||||||
@ -516,7 +516,7 @@ iwconfig_force_preferred() {
|
|||||||
[ $# = 0 ] && return 1
|
[ $# = 0 ] && return 1
|
||||||
|
|
||||||
ewarn "Trying to force preferred in case they are hidden"
|
ewarn "Trying to force preferred in case they are hidden"
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
local found_AP=false i=0 e=
|
local found_AP=false i=0 e=
|
||||||
while [ ${i} -le ${APS} ]; do
|
while [ ${i} -le ${APS} ]; do
|
||||||
eval e=\$SSID_${i}
|
eval e=\$SSID_${i}
|
||||||
@ -541,7 +541,7 @@ iwconfig_connect_preferred() {
|
|||||||
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
||||||
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
||||||
|
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
unset IFS
|
unset IFS
|
||||||
i=0
|
i=0
|
||||||
while [ ${i} -le ${APS} ]; do
|
while [ ${i} -le ${APS} ]; do
|
||||||
@ -571,7 +571,7 @@ iwconfig_connect_not_preferred() {
|
|||||||
if [ -n "${e}" ]; then
|
if [ -n "${e}" ]; then
|
||||||
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
|
||||||
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
|
||||||
for ssid in "$@"; do
|
for ssid; do
|
||||||
if [ "${e}" = "${ssid}" ]; then
|
if [ "${e}" = "${ssid}" ]; then
|
||||||
pref=true
|
pref=true
|
||||||
break
|
break
|
||||||
|
@ -78,7 +78,7 @@ is_older_than() {
|
|||||||
local x= ref="$1"
|
local x= ref="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
[ -e "${x}" ] || continue
|
[ -e "${x}" ] || continue
|
||||||
# We need to check the mtime if it's a directory too as the
|
# We need to check the mtime if it's a directory too as the
|
||||||
# contents may have changed.
|
# 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}")"
|
export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin$(_sanitize_path "${PATH}")"
|
||||||
unset _sanitize_path
|
unset _sanitize_path
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg; do
|
||||||
case "${arg}" in
|
case "${arg}" in
|
||||||
--nocolor|--nocolour|-C)
|
--nocolor|--nocolour|-C)
|
||||||
export RC_NOCOLOR="yes"
|
export RC_NOCOLOR="yes"
|
||||||
|
12
sh/net.sh
12
sh/net.sh
@ -83,7 +83,7 @@ _get_array() {
|
|||||||
case "$(declare -p "$1" 2>/dev/null)" in
|
case "$(declare -p "$1" 2>/dev/null)" in
|
||||||
"declare -a "*)
|
"declare -a "*)
|
||||||
eval "set -- \"\${$1[@]}\""
|
eval "set -- \"\${$1[@]}\""
|
||||||
for _a in "$@"; do
|
for _a; do
|
||||||
printf "%s\n" "${_a}"
|
printf "%s\n" "${_a}"
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
@ -103,7 +103,7 @@ _flatten_array() {
|
|||||||
case "$(declare -p "$1" 2>/dev/null)" in
|
case "$(declare -p "$1" 2>/dev/null)" in
|
||||||
"declare -a "*)
|
"declare -a "*)
|
||||||
eval "set -- \"\${$1[@]}\""
|
eval "set -- \"\${$1[@]}\""
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
|
printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
@ -165,7 +165,7 @@ _configure_variables() {
|
|||||||
|
|
||||||
for var in ${_config_vars}; do
|
for var in ${_config_vars}; do
|
||||||
local v=
|
local v=
|
||||||
for t in "$@"; do
|
for t; do
|
||||||
eval v=\$${var}_${t}
|
eval v=\$${var}_${t}
|
||||||
if [ -n "${v}" ]; then
|
if [ -n "${v}" ]; then
|
||||||
eval ${var}_${IFVAR}=\$${var}_${t}
|
eval ${var}_${IFVAR}=\$${var}_${t}
|
||||||
@ -204,7 +204,7 @@ _gen_module_list() {
|
|||||||
before() {
|
before() {
|
||||||
local mod=${MODULE}
|
local mod=${MODULE}
|
||||||
local MODULE=
|
local MODULE=
|
||||||
for MODULE in "$@"; do
|
for MODULE; do
|
||||||
after "${mod}"
|
after "${mod}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ _load_modules() {
|
|||||||
eval set -- \$module_${i}_program
|
eval set -- \$module_${i}_program
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
x=
|
x=
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
[ -x "${x}" ] && break
|
[ -x "${x}" ] && break
|
||||||
done
|
done
|
||||||
[ -x "${x}" ] || continue
|
[ -x "${x}" ] || continue
|
||||||
@ -327,7 +327,7 @@ _load_modules() {
|
|||||||
fi
|
fi
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
x=
|
x=
|
||||||
for x in "$@"; do
|
for x; do
|
||||||
[ -x "${x}" ] && break
|
[ -x "${x}" ] && break
|
||||||
done
|
done
|
||||||
[ -x "${x}" ] || continue
|
[ -x "${x}" ] || continue
|
||||||
|
Loading…
Reference in New Issue
Block a user