diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-07-03 12:05:24 +0200 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-07-03 12:05:24 +0200 |
commit | 7e2ff917a67573ed957d57d2fd077b4c219c0d86 (patch) | |
tree | 47902df1e57bb4d4a24eccc3f364944bee3bcef3 /src/connections | |
parent | b0373830cd79e35ea0d266726109c36a57122857 (diff) | |
download | netctl-7e2ff917a67573ed957d57d2fd077b4c219c0d86.tar.gz netctl-7e2ff917a67573ed957d57d2fd077b4c219c0d86.tar.xz |
Better grep usage
When possible, fgrep is preferred.
This prevents interpreting variable search patterns as expressions.
In setting the control paths, the search expression was updated to match what wpa_supplicant uses.
Diffstat (limited to 'src/connections')
-rw-r--r-- | src/connections/ethernet | 4 | ||||
-rw-r--r-- | src/connections/wireless | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet index 834b333..b33dfbd 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -45,8 +45,8 @@ ethernet_up() { [[ -z "$WPA_DRIVER" ]] && WPA_DRIVER="wired" # Set wpa_supplicant control path (FS#25473) WPA_CTRL_PATH=/run/wpa_supplicant - if grep "^ *ctrl_interface=" "$WPA_CONF" &>/dev/null; then - WPA_CTRL_PATH=$(grep -m 1 "^ *ctrl_interface=" "$WPA_CONF" | tail -n 1 | cut -d= -f 2- | sed -r 's/DIR=(.*) +GROUP=.*/\1/') + if grep -q "^ *ctrl_interface=" "$WPA_CONF"; then + WPA_CTRL_PATH=$(grep -m 1 "^ *ctrl_interface=" "$WPA_CONF" | cut -d= -f 2- | sed -r 's/^DIR=(.*) GROUP=.*/\1/') fi report_debug ethernet_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS" diff --git a/src/connections/wireless b/src/connections/wireless index efcda80..143276b 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -25,8 +25,8 @@ wireless_up() { if [[ "$SECURITY" = "wpa-config" ]]; then WPA_CONF="${WPA_CONF:-/etc/wpa_supplicant.conf}" # Use defined control path (FS#24949) - if grep "^ *ctrl_interface=" "$WPA_CONF" &>/dev/null; then - WPA_CTRL_PATH=$(grep -m 1 "^ *ctrl_interface=" "$WPA_CONF" | tail -n 1 | cut -d= -f 2- | sed -r 's/DIR=(.*) +GROUP=.*/\1/') + if grep -q "^ *ctrl_interface=" "$WPA_CONF"; then + WPA_CTRL_PATH=$(grep -m 1 "^ *ctrl_interface=" "$WPA_CONF" | cut -d= -f 2- | sed -r 's/^DIR=(.*) GROUP=.*/\1/') fi else WPA_CONF=$(make_wpa_config_file $INTERFACE) |