From cbd00d5652700792a7833617d947f8a78bb34ccc Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Sun, 21 Jul 2013 00:51:34 +0200 Subject: Introduce sed Instead of filtering results from grep, we can also just use sed. Installations having grep can be expected to have sed as well. --- src/lib/connections/wireless | 2 +- src/lib/wpa | 3 +-- src/wifi-menu | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/connections/wireless b/src/lib/connections/wireless index fe01b90..870af51 100644 --- a/src/lib/connections/wireless +++ b/src/lib/connections/wireless @@ -17,7 +17,7 @@ wireless_up() { : ${Security:=none} : ${WPADriver:=nl80211,wext} : ${TimeoutWPA:=15} - + if [[ $RFKill ]]; then enable_rf "$Interface" "$RFKill" || return 1 fi diff --git a/src/lib/wpa b/src/lib/wpa index 65ef8f9..b80c54d 100644 --- a/src/lib/wpa +++ b/src/lib/wpa @@ -12,8 +12,7 @@ wpa_call() { if [[ $WPA_CTRL_DIR ]]; then args+=("-p" "$WPA_CTRL_DIR") elif [[ $WPAConfigFile ]] && grep -q "^[[:space:]]*ctrl_interface=" "$WPAConfigFile"; then - WPA_CTRL_DIR=$(grep -m1 "^[[:space:]]*ctrl_interface=" "$WPAConfigFile") - WPA_CTRL_DIR=${WPA_CTRL_DIR#*ctrl_interface=} + WPA_CTRL_DIR=$(sed -n "0,/^[[:space:]]*ctrl_interface=/s///p" "$WPAConfigFile") if [[ $WPA_CTRL_DIR == DIR=* ]]; then WPA_CTRL_DIR=${WPA_CTRL_DIR:4} WPA_CTRL_DIR=${WPA_CTRL_DIR%% GROUP=*} diff --git a/src/wifi-menu b/src/wifi-menu index d0903aa..a62881e 100755 --- a/src/wifi-menu +++ b/src/wifi-menu @@ -111,8 +111,7 @@ create_profile() key=$(dialog $box "$msg" 10 40 --stdout) || return $? if [[ "${#key}" -ge 8 && "${#key}" -le 63 ]]; then if [[ "$OBSCURE" ]]; then - key=$(wpa_passphrase "$1" "$key" | grep -m 1 "^[[:space:]]*psk=") - key=${key#*psk=} + key=$(wpa_passphrase "$1" "$key" | sed -n "s/^[[:space:]]*psk=//p") else key=$(printf "%q" "$key") fi @@ -210,8 +209,7 @@ if [[ ! -d "/sys/class/net/$INTERFACE" ]]; then fi echo -n "Scanning for networks... " -CONNECTION=$(wpa_call "$INTERFACE" status 2> /dev/null | grep -m 1 "^ssid=") -CONNECTION=${CONNECTION#ssid=} +CONNECTION=$(wpa_call "$INTERFACE" status 2> /dev/null | sed -n "s/^ssid=//p") NETWORKS=$(wpa_supplicant_scan "$INTERFACE" 3,4,5) if [[ $? -eq 0 ]]; then trap 'rm -f "$NETWORKS"' EXIT -- cgit v1.2.3-24-g4f1b