diff options
author | Jim Pryor <profjim@jimpryor.net> | 2009-09-14 05:43:38 +0200 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2009-09-14 08:23:56 +0200 |
commit | 2e0232ccf156498b81c06044890e59fb4a6b7943 (patch) | |
tree | eb9a2fd1fc0f0b1a7d0797179368ed42b3d6db80 /src | |
parent | deed4d3d3cff0fa45d0d0d5aa665db102cdc5ff3 (diff) | |
download | netctl-2e0232ccf156498b81c06044890e59fb4a6b7943.tar.gz netctl-2e0232ccf156498b81c06044890e59fb4a6b7943.tar.xz |
Returns and exits
* add some abortive returns
* some exit tweaks
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/connections/wireless | 6 | ||||
-rw-r--r-- | src/netcfg | 8 | ||||
-rw-r--r-- | src/network | 2 | ||||
-rw-r--r-- | src/wireless | 12 |
4 files changed, 18 insertions, 10 deletions
diff --git a/src/connections/wireless b/src/connections/wireless index 0e7e274..955f957 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -11,12 +11,14 @@ wireless_up() { . "$SUBR_DIR/wireless" if [[ -n "$RFKILL" ]]; then - if [[ ! "$(get_rf_state "$INTERFACE")" == "up" ]]; then + local state=$(get_rf_state "$INTERFACE") || return 1 + if [[ "$state" != "up" ]]; then if [[ "$RFKILL" == "soft" ]]; then set_rf_state "$INTERFACE" up sleep 1 else report_fail "radio is disabled on $INTERFACE" + return 1 fi fi fi @@ -218,7 +220,7 @@ wireless_down() { # Any reason why a hardware switch should be considered on interface down? if [[ "$RFKILL" == "soft" ]]; then . "$SUBR_DIR/wireless" - set_rf_state "$INTERFACE" down + set_rf_state "$INTERFACE" down || return 1 fi } @@ -28,7 +28,6 @@ usage() echo "-v, version Output version information and exit" echo " all-resume Resume previously suspended profiles and reconnect them" echo " all-suspend Store a list of current running profiles and suspend them" - exit 1 } # TODO: Re-add ROOT check and rewrite with getopts from BashFAQ @@ -38,7 +37,8 @@ case "$1" in version exit 0;; --help|-h|help) - usage;; + usage + exit 0;; list|-l) echo "Available Profiles" echo "------------------" @@ -84,12 +84,14 @@ case "$1" in all-suspend) all_suspend;; -*|--*) - usage;; + usage + exit 1;; *) if [[ -n "$1" ]]; then profile_up "$1" else usage + exit 1 fi ;; esac diff --git a/src/network b/src/network index f1f55cf..678fbb3 100644 --- a/src/network +++ b/src/network @@ -267,8 +267,8 @@ check_iface() { else echo "up" fi - exit 0 ) + return 0 else return 1 fi diff --git a/src/wireless b/src/wireless index 713beb2..d118919 100644 --- a/src/wireless +++ b/src/wireless @@ -136,7 +136,7 @@ wpa_supplicant_scan_info() { [[ -z "$INTERFACE" ]] && return 1 essids=$(mktemp --tmpdir essid.XXXXXXXX) - wpa_supplicant -B -i"$INTERFACE" -Dwext -C/var/run/wpa_supplicant -P/var/run/wpa_supplicant.pid + wpa_supplicant -B -i"$INTERFACE" -Dwext -C/var/run/wpa_supplicant -P/var/run/wpa_supplicant.pid || return 1 wpa_cli -i "$INTERFACE" scan &> /dev/null sleep 2.5 wpa_cli -i "$INTERFACE" scan_results | @@ -169,8 +169,11 @@ wpa_supplicant_scan_info() { set_rf_state() { local INTERFACE="$1" state="$2" PROFILE="$3" - [[ $RFKILL == "hard" ]] && report_fail "Cannot set state on hardware rfkill switch" - local path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") + if [[ "$RFKILL" == "hard" ]] + report_fail "Cannot set state on hardware rfkill switch" + return 1 + fi + local path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") || return 1 case "$state" in up) echo 1 > "$path/state" @@ -200,12 +203,13 @@ get_rf_path() { fi report_fail "no rfkill switch available on interface $INTERFACE" fi + return 1 } get_rf_state() { local INTERFACE="$1" PROFILE="$2" path state - path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") + path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") || return 1 state=$(cat "$path/state") case "$state" in |