Skip to content

Commit

Permalink
wifi-connect: Use Bash "safe mode"
Browse files Browse the repository at this point in the history
In order to make the script more robust, this commit enables Bash's "safe
mode", such that commands that exit non-zero will cause the script to fail, as
will referenced to uninitialised variables.
  • Loading branch information
Allan Lewis committed May 21, 2019
1 parent 49dea32 commit 04c3cf5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wifi-connect
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

# Read SSID
ssid=
if [ -z "${1+x}" ]; then
Expand All @@ -18,7 +20,7 @@ fi
timeout=$(( $(date +%s) + 60 ))
info=
while true; do
info=$(nmcli dev wifi list | grep "${ssid}")
info=$(nmcli dev wifi list | grep "${ssid}" || true)
if [[ -n "${info}" ]]; then
break
else
Expand Down

0 comments on commit 04c3cf5

Please sign in to comment.