summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Pryor <profjim@jimpryor.net>2009-08-11 14:05:16 +0200
committerJames Rayner <james@archlinux.org>2009-08-15 04:28:31 +0200
commit09a2212f344e5bdf7573584a9b8ef5b64c7b1fac (patch)
treeea813dcebf776401161a6fc3b4761710b2a0d2e2
parent07aa8f784896ba97914f4b2a71d2ba6c0047cb07 (diff)
downloadnetctl-09a2212f344e5bdf7573584a9b8ef5b64c7b1fac.tar.gz
netctl-09a2212f344e5bdf7573584a9b8ef5b64c7b1fac.tar.xz
quotes!
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
-rw-r--r--src-wireless/net-auto8
-rw-r--r--src-wireless/netcfg-auto-wireless4
-rw-r--r--src/8021x6
-rw-r--r--src/connections/ethernet28
-rw-r--r--src/connections/ethernet-iproute26
-rw-r--r--src/connections/ppp10
-rw-r--r--src/connections/wireless46
-rw-r--r--src/net-profiles8
-rw-r--r--src/net-rename2
-rw-r--r--src/netcfg14
-rw-r--r--src/netcfg-menu10
-rw-r--r--src/network61
-rw-r--r--src/wireless6
13 files changed, 114 insertions, 115 deletions
diff --git a/src-wireless/net-auto b/src-wireless/net-auto
index c1e9d70..cf99270 100644
--- a/src-wireless/net-auto
+++ b/src-wireless/net-auto
@@ -18,9 +18,9 @@ case "$1" in
# TODO: check if any way of using 'stacks' in bash
rm -f "$STATE_DIR/net-auto"
- for iface in ${AUTO_NETWORKS[@]}; do
+ for iface in "${AUTO_NETWORKS[@]}"; do
if [[ "${iface:0:4}" = "auto" ]]; then
- auto=$iface
+ auto="$iface"
elif [[ "$auto" ]]; then
if /usr/bin/netcfg-"$auto" "$iface"; then
echo "$iface" >> "$STATE_DIR/net-auto"
@@ -36,13 +36,13 @@ case "$1" in
fi
for iface in $(cat "$STATE_DIR/net-auto"); do
- netcfg iface-down $iface
+ netcfg iface-down "$iface"
done
rm -f "$STATE_DIR/net-auto"
rm_daemon net-auto
;;
restart)
- $0 stop; sleep 1; $0 start
+ "$0" stop; sleep 1; "$0" start
;;
*)
exit_stderr "Usage: $0 {start|stop|restart}"
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless
index 24edcfb..bbee281 100644
--- a/src-wireless/netcfg-auto-wireless
+++ b/src-wireless/netcfg-auto-wireless
@@ -80,8 +80,8 @@ wifi_auto()
if [[ $(id -u) -ne 0 ]]; then
exit_stderr "This script needs to be run with root privileges"
fi
-if [[ -z $1 ]]; then
+if [[ -z "$1" ]]; then
exit_stderr "Please supply an interface to connect"
fi
-wifi_auto $1
+wifi_auto "$1"
diff --git a/src/8021x b/src/8021x
index 271e760..25c9cc1 100644
--- a/src/8021x
+++ b/src/8021x
@@ -2,9 +2,9 @@
# wpa_check interface [timeout]
wpa_check()
{
- local timeout=0 INTERFACE=$1 TIMEOUT=${2:-15}
+ local timeout=0 INTERFACE="$1" TIMEOUT="${2:-15}"
- while [[ $timeout -lt $TIMEOUT ]]; do
+ while [[ $timeout -lt "$TIMEOUT" ]]; do
( # Sometimes wpa_supplicant isn't ready so silence errors for 2s only to avoid hiding real errors
if [[ $timeout -lt 2 ]]; then
eval $(wpa_cli -i "$INTERFACE" status 2> /dev/null | fgrep "wpa_state=")
@@ -29,7 +29,7 @@ start_wpa()
shift 2
local WPA_OPTS="$*"
- wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "${INTERFACE}" -c "$WPA_CONF" $WPA_OPTS
+ wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -c "$WPA_CONF" $WPA_OPTS
sleep 1
if [[ ! -f "/var/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 71124d0..22405ad 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -2,7 +2,7 @@
. /usr/lib/network/network
ethernet_up() {
- load_profile $1
+ load_profile "$1"
if [[ ! -e /sys/class/net/"$INTERFACE" ]]; then
if ! echo "$INTERFACE"| fgrep ":"; then
@@ -15,7 +15,7 @@ ethernet_up() {
set_interface up-old "$INTERFACE"
# don't think it's possible to detect carrier using ifconfig alone (at least, not without ifdown/ifupping the interface)
- if [[ $(cat /sys/class/net/$INTERFACE/carrier 2>/dev/null) -ne 1 ]]; then # gives err if iface inactive (i.e. ifdown)
+ if [[ $(cat "/sys/class/net/$INTERFACE/carrier" 2>/dev/null) -ne 1 ]]; then # gives err if iface inactive (i.e. ifdown)
report_fail "No connection"
return 1
fi
@@ -38,18 +38,18 @@ ethernet_up() {
fi
fi
- case $IP in
+ case "$IP" in
dhcp)
if checkyesno "${DHCLIENT:-no}"; then
- rm -r /var/run/dhclient-${INTERFACE}.pid >/dev/null 2>&1
+ rm -r "/var/run/dhclient-${INTERFACE}.pid" >/dev/null 2>&1
report_debug ethernet_up dhclient -q -e TIMEOUT="${DHCP_TIMEOUT:-10}" -pf "/var/run/dhclient-$INTERFACE.pid" "$INTERFACE"
- if ! dhclient -q -e TIMEOUT="${DHCP_TIMEOUT:-10}" -pf /var/run/dhclient-${INTERFACE}.pid $INTERFACE; then
+ if ! dhclient -q -e TIMEOUT="${DHCP_TIMEOUT:-10}" -pf "/var/run/dhclient-${INTERFACE}.pid" "$INTERFACE"; then
report_fail "DHCP IP lease attempt failed."
return 1
fi
else
# Clear remaining pid files.
- rm -f /var/run/dhcpcd-${INTERFACE}.{pid,cache} >/dev/null 2>&1
+ rm -f "/var/run/dhcpcd-${INTERFACE}".{pid,cache} >/dev/null 2>&1
# If using own dns, tell dhcpcd to NOT replace resolv.conf
[[ -n "$DNS1" || -n "$DNS" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS"
# Start dhcpcd
@@ -75,7 +75,7 @@ ethernet_up() {
# bring up the default route (gateway)
if [[ -n "$GATEWAY" ]]; then
report_debug ethernet_up route add default gw "$GATEWAY"
- if ! route add default gw $GATEWAY; then
+ if ! route add default gw "$GATEWAY"; then
# JP: don't we want to add this to all the aborts?
# ignore quirk nodown---is that appropriate?
# this adds a flush call as well---is that appropriate?
@@ -119,16 +119,16 @@ ethernet_up() {
}
ethernet_down() {
- load_profile $1
- case $IP in
+ load_profile "$1"
+ case "$IP" in
dhcp)
if checkyesno "${DHCLIENT:-no}"; then
- if [[ -f /var/run/dhclient-${INTERFACE}.pid ]]; then
+ if [[ -f "/var/run/dhclient-${INTERFACE}.pid" ]]; then
report_debug ethernet_down kill dhclient
- kill $(cat /var/run/dhclient-${INTERFACE}.pid)
+ kill $(cat "/var/run/dhclient-${INTERFACE}.pid")
fi
else
- if [[ -f /var/run/dhcpcd-${INTERFACE}.pid ]]; then
+ if [[ -f "/var/run/dhcpcd-${INTERFACE}.pid" ]]; then
report_debug ethernet_down dhcpcd -qx "$INTERFACE"
dhcpcd -qx "$INTERFACE" &>/dev/null
fi
@@ -137,7 +137,7 @@ ethernet_down() {
static)
if [[ -n "$GATEWAY" ]]; then
report_debug ethernet_down route del default gw "$GATEWAY"
- route del default gw $GATEWAY
+ route del default gw "$GATEWAY"
fi
;;
esac
@@ -155,6 +155,6 @@ ethernet_status() {
fi
}
-ethernet_$1 $2
+ethernet_$1 "$2"
exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute
index c50fd7d..385e128 100644
--- a/src/connections/ethernet-iproute
+++ b/src/connections/ethernet-iproute
@@ -9,9 +9,9 @@ report_iproute()
}
ethernet_up() {
- load_profile $1
+ load_profile "$1"
- if [[ ! -e /sys/class/net/$INTERFACE ]]; then
+ if [[ ! -e "/sys/class/net/$INTERFACE" ]]; then
if ! echo "$INTERFACE" | fgrep -q ":"; then
report_iproute "Interface $INTERFACE does not exist"
fi
@@ -24,8 +24,8 @@ ethernet_up() {
report_iproute "No connection"
fi
- if checkyesno ${AUTH8021X:-no}; then
- . ${SUBR_DIR}/8021x
+ if checkyesno "${AUTH8021X:-no}"; then
+ . "${SUBR_DIR}/8021x"
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired"
@@ -44,10 +44,10 @@ ethernet_up() {
fi
fi
- case $IP in
+ case "$IP" in
dhcp)
# Clear remaining pid files.
- rm -f /var/run/dhcpcd-${INTERFACE}.{pid,cache} >/dev/null 2>&1
+ rm -f "/var/run/dhcpcd-${INTERFACE}".{pid,cache} >/dev/null 2>&1
# If using own dns, tell dhcpcd to NOT replace resolv.conf
[[ -n "$DNS" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS"
@@ -61,13 +61,13 @@ ethernet_up() {
static)
if [[ -n "$ADDR" ]]; then
report_debug ethernet_iproute_up ip addr add "$ADDR/24" brd + dev "$INTERFACE"
- if ! ip addr add ${ADDR}/24 brd + dev $INTERFACE; then
+ if ! ip addr add "${ADDR}/24" brd + dev "$INTERFACE"; then
report_iproute "Could not configure interface"
fi
fi
if [[ -n "$GATEWAY" ]]; then
report_debug ethernet_iproute_up ip route add default via "$GATEWAY"
- if ! ip route add default via $GATEWAY; then
+ if ! ip route add default via "$GATEWAY"; then
report_iproute "Adding gateway $GATEWAY failed"
fi
fi
@@ -90,7 +90,7 @@ ethernet_up() {
# Set hostname
if [[ -n "$HOSTNAME" ]]; then
report_debug ethernet_iproute_up hostname "$HOSTNAME"
- if ! hostname $HOSTNAME; then
+ if ! hostname "$HOSTNAME"; then
report_iproute "Cannot set hostname"
fi
fi
@@ -102,7 +102,7 @@ ethernet_up() {
[[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf
if [[ -n "$DNS" ]]; then
- for dns in ${DNS[@]}; do
+ for dns in "${DNS[@]}"; do
echo "nameserver $dns" >>/etc/resolv.conf
done
fi
@@ -111,10 +111,10 @@ ethernet_up() {
}
ethernet_down() {
- load_profile $1
+ load_profile "$1"
if [[ "$IP" == "dhcp" ]]; then
- if [[ -f /var/run/dhcpcd-${INTERFACE}.pid ]]; then
+ if [[ -f "/var/run/dhcpcd-${INTERFACE}.pid" ]]; then
report_debug ethernet_iproute_down dhcpcd -qx "$INTERFACE"
dhcpcd -qx "$INTERFACE" &>/dev/null
fi
@@ -134,6 +134,6 @@ ethernet_status() {
fi
}
-ethernet_$1 $2
+ethernet_$1 "$2"
exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/connections/ppp b/src/connections/ppp
index c59db40..c50fee1 100644
--- a/src/connections/ppp
+++ b/src/connections/ppp
@@ -3,11 +3,11 @@
ppp_up() {
- load_profile $1
+ load_profile "$1"
[[ -z "$PEER" ]] && PEER="provider"
[[ -z "$PPP_TIMEOUT" ]] && PPP_TIMEOUT=30
- /usr/sbin/pppd call $PEER updetach child-timeout $PPP_TIMEOUT linkname $PEER
+ /usr/sbin/pppd call "$PEER" updetach child-timeout "$PPP_TIMEOUT" linkname "$PEER"
if [[ $? -ne 0 ]]; then
report_fail "Couldn't make pppd connection."
@@ -16,10 +16,10 @@ ppp_up() {
}
ppp_down() {
- load_profile $1
- kill $(head -1 /var/run/ppp-$(basename $PEER).pid)
+ load_profile "$1"
+ kill $(head -1 "/var/run/ppp-$(basename $PEER).pid")
}
-ppp_$1 $2
+ppp_$1 "$2"
exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/connections/wireless b/src/connections/wireless
index c50acfa..a0191b6 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -16,11 +16,11 @@ rfkill_from_name() {
wireless_up() {
- load_profile $1
+ load_profile "$1"
[[ -n "$2" ]] && ESSID="$2" # JP: use the literal ESSID (though currently we only interpret wireless-dbus ESSIDs as regexps)
- . ${SUBR_DIR}/8021x
- . ${SUBR_DIR}/wireless
+ . "${SUBR_DIR}/8021x"
+ . "${SUBR_DIR}/wireless"
# If rfkill is specified, enable device.
if [[ -n "$RFKILL_NAME" ]]; then
@@ -46,9 +46,9 @@ wireless_up() {
# Most drivers (mac80211) need mode set before device is brought up
# Drivers generally default to managed, but set this to be sure.
- if [[ $(iwgetid -sm $INTERFACE) -ne Managed ]]; then
+ if [[ $(iwgetid -sm "$INTERFACE") -ne Managed ]]; then
report_debug wireless_up iwconfig "$INTERFACE" mode managed
- iwconfig $INTERFACE mode managed
+ iwconfig "$INTERFACE" mode managed
fi
report_debug wireless_up ifup
@@ -63,7 +63,7 @@ wireless_up() {
fi
fi
- if checkyesno ${SCAN:-no}; then
+ if checkyesno "${SCAN:-no}"; then
report_debug wireless_up scanning
local OLDESSID="$ESSID"
if [[ -n "$AP" ]]; then
@@ -81,13 +81,13 @@ wireless_up() {
# Manually set iwconfig options
if [[ "$IWCONFIG" ]]; then
report_debug wireless_up iwconfig "$INTERFACE" $IWCONFIG
- iwconfig $INTERFACE $IWCONFIG
+ iwconfig "$INTERFACE" $IWCONFIG
fi
# Set to 'none' if not set
[[ -z "$SECURITY" ]] && SECURITY="none"
- case $SECURITY in
+ case "$SECURITY" in
wep|none)
# 'none' uses iwconfig like wep. Use sane default if WEP_OPTS=""
if [[ -z "$WEP_OPTS" ]]; then
@@ -123,7 +123,7 @@ wireless_up() {
fi
report_debug ethernet_up wep_check
- if ! wep_check $INTERFACE $TIMEOUT; then
+ if ! wep_check "$INTERFACE" "$TIMEOUT"; then
report_fail "WEP Association Failed"
return 1
fi
@@ -169,7 +169,7 @@ wireless_up() {
fi
;;
wpa-config)
- . ${SUBR_DIR}/8021x
+ . "${SUBR_DIR}/8021x"
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
@@ -186,27 +186,27 @@ wireless_up() {
esac
conn=ethernet
- checkyesno ${IPROUTE:-no} && conn=ethernet-iproute
- if ! ${CONN_DIR}/$conn up $1; then
- wireless_down $1 YES
+ checkyesno "${IPROUTE:-no}" && conn=ethernet-iproute
+ if ! "${CONN_DIR}/$conn" up "$1"; then
+ wireless_down "$1" YES
return 1
fi
}
wireless_down() {
- PROFILE=$1 NOETHERNETDOWN=$2
- load_profile $PROFILE
- . ${SUBR_DIR}/8021x
- if ! checkyesno $NOETHERNETDOWN; then
+ local PROFILE="$1" NOETHERNETDOWN="$2"
+ load_profile "$PROFILE"
+ . "${SUBR_DIR}/8021x"
+ if ! checkyesno "$NOETHERNETDOWN"; then
conn=ethernet
- checkyesno ${IPROUTE:-no} && conn=ethernet-iproute
- $CONN_DIR/$conn down $PROFILE
+ checkyesno "${IPROUTE:-no}" && conn=ethernet-iproute
+ "$CONN_DIR/$conn" down "$PROFILE"
fi
report_debug wireless_down stop_wpa "$INTERFACE"
- stop_wpa $INTERFACE
+ stop_wpa "$INTERFACE"
[[ "$SECURITY" == "wpa" ]] && rm -rf "/tmp/wpa.${PROFILE// /}" # remove tmp wpa config
report_debug wireless_down iwconfig "$INTERFACE" essid off key off
- iwconfig $INTERFACE essid off key off &> /dev/null
+ iwconfig "$INTERFACE" essid off key off &> /dev/null
# respects quirk nodown---is that appropriate?
# wasn't this already called in ethernet_down? but does the call there respect quirk nodown?
# this adds a flush call as well---is that appropriate?
@@ -214,11 +214,11 @@ wireless_down() {
# If rfkill is specified, disable device.
if [[ -n "$RFKILL_NAME" ]]; then
- path=$(rfkill_from_name $RFKILL_NAME)
+ path=$(rfkill_from_name "$RFKILL_NAME")
if [[ $? -ne 0 ]]; then
report_fail "no rfkill switch with the name $RFKILL_NAME";
fi
- echo 0 > ${path}/state
+ echo 0 > "${path}/state"
fi
}
diff --git a/src/net-profiles b/src/net-profiles
index 152d803..129aaed 100644
--- a/src/net-profiles
+++ b/src/net-profiles
@@ -21,7 +21,7 @@ case "$1" in
[ ! "$NETWORKS_MENU_TIMEOUT" ] && NETWORKS_MENU_TIMEOUT=5
if [[ "$NET" = "menu" ]]; then
- if /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT; then
+ if /usr/bin/netcfg-menu "$NETWORKS_MENU_TIMEOUT"; then
mv "$STATE_DIR"/{menu,net-profiles} # JP: user may want to disconnect profile by calling net-profiles stop
add_daemon net-profiles
exit 0
@@ -34,8 +34,8 @@ case "$1" in
fi
else
# No NET= passed at boot, go to NETWORKS=()
- for network in ${NETWORKS[@]}; do
- case $network in
+ for network in "${NETWORKS[@]}"; do
+ case "$network" in
menu) # Pull up menu of networks
if /usr/bin/netcfg-menu "$NETWORKS_MENU_TIMEOUT"; then
mv "$STATE_DIR"/{menu,net-profiles} # JP: user may want to disconnect profile by calling net-profiles stop
@@ -72,7 +72,7 @@ case "$1" in
rm_daemon net-profiles
;;
restart)
- $0 stop; sleep 1; $0 start
+ "$0" stop; sleep 1; "$0" start
;;
*)
exit_stderr "Usage: $0 {start|stop|restart}"
diff --git a/src/net-rename b/src/net-rename
index 25a38ed..c8927ed 100644
--- a/src/net-rename
+++ b/src/net-rename
@@ -16,7 +16,7 @@ case "$1" in
/bin/true
;;
restart)
- $0 start
+ "$0" start
;;
*)
exit_stderr "Usage: $0 {start|stop|restart}"
diff --git a/src/netcfg b/src/netcfg
index bd0dc6a..197848a 100644
--- a/src/netcfg
+++ b/src/netcfg
@@ -60,8 +60,8 @@ fi
case "$1" in
-c|check-iface|-u|up)
- CHECK="YES";
- profile_up $2;;
+ CHECK="YES"
+ profile_up "$2";;
clean)
rm "$STATE_DIR/interfaces"/* 2> /dev/null
rm "$STATE_DIR/profiles"/* 2> /dev/null
@@ -71,14 +71,14 @@ case "$1" in
killall dhcpcd 2> /dev/null
;;
-d|down)
- profile_down $2;;
+ profile_down "$2";;
-i|iface-down)
- interface_down $2;;
+ interface_down "$2";;
-a|all-down)
all_down;;
-r|reconnect)
- profile_down $2
- profile_up $2;;
+ profile_down "$2"
+ profile_up "$2";;
all-resume)
all_resume;;
all-suspend)
@@ -87,7 +87,7 @@ case "$1" in
usage;;
*)
if [ -n "$1" ]; then
- profile_up $1
+ profile_up "$1"
else
usage
fi
diff --git a/src/netcfg-menu b/src/netcfg-menu
index 1d740fb..21b5651 100644
--- a/src/netcfg-menu
+++ b/src/netcfg-menu
@@ -12,8 +12,8 @@ while read prof; do
# if there is a profile called "main", Use as default
[ "$prof" = "main" ] && DEFAULT=$prof
unset DESCRIPTION # JP: we can''t sandbox the sourced profiles, because we need to expose profiles[]
- . $PROFILE_DIR/$prof
- profiles[$i]=$prof
+ . "$PROFILE_DIR/$prof"
+ profiles[$i]="$prof"
i=$((i+1))
profiles[$i]="$DESCRIPTION" # JP: this will usually have spaces and must be quoted
i=$((i+1))
@@ -25,7 +25,7 @@ fi
[ "$NETWORKS_MENU_DEFAULT" ] && DEFAULT="$NETWORKS_MENU_DEFAULT"
# if no default yet, use the first entry
-[ "$DEFAULT" = "" ] && DEFAULT=${profiles[0]}
+[ "$DEFAULT" = "" ] && DEFAULT="${profiles[0]}"
ANSWER=$(mktemp /tmp/menu.XXXXXXXX) || exit 1
# Set timeout
@@ -36,9 +36,9 @@ else
fi
# Display Dialog
-dialog --timeout $TIMEOUT --default-item $DEFAULT \
+dialog --timeout "$TIMEOUT" --default-item "$DEFAULT" \
--menu "Select the network profile you wish to use" \
- 13 50 6 "${profiles[@]}" 2>$ANSWER
+ 13 50 6 "${profiles[@]}" 2> $ANSWER
ret=$?
diff --git a/src/network b/src/network
index 12920de..8b1c088 100644
--- a/src/network
+++ b/src/network
@@ -7,24 +7,24 @@
# load_profile profile
# source the profile
load_profile() {
- validate_profile $1 || return 1
- . $PROFILE_DIR/$1
+ validate_profile "$1" || return 1
+ . "$PROFILE_DIR/$1"
}
# validate_profile profile
# check whether profile exists and is usable
validate_profile()
{
[[ -z "$1" ]] && return 1
- if [[ ! -f $PROFILE_DIR/$1 ]]; then
+ if [[ ! -f "$PROFILE_DIR/$1" ]]; then
report_fail "Profile \"$1\" does not exist"
return 1
fi
- . $PROFILE_DIR/$1
+ . "$PROFILE_DIR/$1"
if [[ -z "$INTERFACE" ]]; then
report_fail "Profile missing an interface to configure"
return 1
fi
- if [[ ! -f $CONN_DIR/$CONNECTION ]]; then
+ if [[ ! -f "$CONN_DIR/$CONNECTION" ]]; then
report_fail "$CONNECTION is not a valid connection, check spelling or look at examples"
return 1
fi
@@ -110,7 +110,7 @@ profile_up()
# NETWORKS_EXCLUSIVE, rc.conf: Profiles are globally mutually exclusive
# EXCLUSIVE, network.d/profile: Individual profile is mutually exclusive
- if checkyesno $NETWORKS_EXCLUSIVE || checkyesno $EXCLUSIVE; then
+ if checkyesno "$NETWORKS_EXCLUSIVE" || checkyesno "$EXCLUSIVE"; then
all_down
fi
@@ -123,7 +123,7 @@ profile_up()
exit 1
else
interface_down $INTERFACE || exit 1
- load_profile "$PROFILE"
+ load_profile "$PROFILE"
fi
;;
external)
@@ -223,9 +223,9 @@ profile_down()
# Check if variable is a member of an array
inarray()
{
-search=$1
+search="$1"
shift
-for item in $*; do
+for item in "$@"; do
if [[ "$item" == "$search" ]]; then
return 0
fi
@@ -234,7 +234,7 @@ return 1
}
quirk() {
-inarray $1 ${QUIRKS[@]}
+inarray "$1" "${QUIRKS[@]}"
return $?
}
@@ -243,22 +243,21 @@ return $?
#
interface_down()
{
- local prof=$(get_iface_prof $1)
- profile_down $prof
+ local prof=$(get_iface_prof "$1")
+ profile_down "$prof"
return $?
}
-### Query functions
##
# check_iface interface
# Return 0 if interface up
# Return 1 if interface down
#
check_iface() {
- if [[ -f $STATE_DIR/interfaces/$1 ]]; then (
- . $STATE_DIR/interfaces/$1
- if [[ $PROFILE -eq external ]]; then
+ if [[ -f "$STATE_DIR/interfaces/$1" ]]; then (
+ . "$STATE_DIR/interfaces/$1"
+ if [[ "$PROFILE" -eq external ]]; then
echo "external"
else
echo "up"
@@ -275,9 +274,9 @@ check_iface() {
# Return 1 if down.
#
get_iface_prof() {
- if check_iface $1; then
- . $STATE_DIR/interfaces/$1
- echo $PROFILE
+ if check_iface "$1"; then
+ . "$STATE_DIR/interfaces/$1"
+ echo "$PROFILE"
else
return 1
fi
@@ -294,7 +293,7 @@ list_profiles() {
# Return 1 if profile not registered
#
check_profile() {
- [[ -f $STATE_DIR/profiles/$1 && ! -f "$STATE_DIR/suspend/$1" ]] && return 0
+ [[ -f "$STATE_DIR/profiles/$1" && ! -f "$STATE_DIR/suspend/$1" ]] && return 0
return 1
}
@@ -306,16 +305,16 @@ check_profile() {
set_profile() {
if [[ "$1" == "up" ]]; then
( # subshell creates sandbox for sourced variables
- . $PROFILE_DIR/$2
- cp $PROFILE_DIR/$2 $STATE_DIR/profiles/
- echo $2 > $STATE_DIR/last_profile
- set_iface up $INTERFACE $2
+ . "$PROFILE_DIR/$2"
+ cp "$PROFILE_DIR/$2" "$STATE_DIR/profiles/"
+ echo "$2" > "$STATE_DIR/last_profile"
+ set_iface up "$INTERFACE" "$2"
)
elif [[ "$1" == "down" && -f "$STATE_DIR/profiles/$2" ]]; then # JP: skip if profile not already up
( # subshell
- . $STATE_DIR/profiles/$2
- rm $STATE_DIR/profiles/$2
- set_iface down $INTERFACE $2
+ . "$STATE_DIR/profiles/$2"
+ rm "$STATE_DIR/profiles/$2"
+ set_iface down "$INTERFACE" "$2"
)
fi
}
@@ -325,10 +324,10 @@ set_profile() {
# optionally link it to a profile.
#
set_iface() {
- PROFILE=$3
+ local PROFILE="$3"
[[ -z "$PROFILE" ]] && PROFILE=external
if [[ "$1" == "up" ]]; then
- echo "PROFILE=$PROFILE" > $STATE_DIR/interfaces/$2
+ echo "PROFILE=$PROFILE" > "$STATE_DIR/interfaces/$2"
elif [[ "$1" == "down" ]]; then
rm -f "$STATE_DIR/interfaces/$2" # JP: add -f so we don't complain if the interface isn't up
fi
@@ -376,9 +375,9 @@ set_interface()
#
checkyesno()
{
- _value=${1}
+ local _value="${1}"
#debug "checkyesno: $1 is set to $_value."
- case $_value in
+ case "$_value" in
# "yes", "true", "on", or "1"
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
diff --git a/src/wireless b/src/wireless
index ff20806..d3eb79c 100644
--- a/src/wireless
+++ b/src/wireless
@@ -2,10 +2,10 @@
# wep_check interface [timeout]
wep_check()
{
- local INTERFACE=$1 TIMEOUT=${2:-15} timeout=0 bssid
+ local INTERFACE="$1" TIMEOUT="${2:-15}" timeout=0 bssid
- while [[ $timeout -ne $TIMEOUT ]]; do
- bssid=`iwgetid $INTERFACE -ra`
+ while [[ $timeout -lt "$TIMEOUT" ]]; do
+ bssid=$(iwgetid "$INTERFACE" -ra)
[[ -n "$bssid" && "$bssid" != "00:00:00:00:00:00" ]] && return 0
sleep 1
let timeout++