minor fixes to satisfy shellcheck

This commit is contained in:
Maarten van Gompel 2021-03-31 20:14:53 +02:00
parent ae3e1edd9c
commit da3dba4bfb
2 changed files with 5 additions and 3 deletions

View file

@ -229,7 +229,8 @@ mainloop() {
while read -r line; do while read -r line; do
if echo "$line" | grep -E "^signal.*StateChanged"; then if echo "$line" | grep -E "^signal.*StateChanged"; then
rm /tmp/modem.*.state 2>/dev/null rm /tmp/modem.*.state 2>/dev/null
read -r oldstate # shellcheck disable=SC2034
read -r oldstate #unused but we need to read past it
read -r newstate read -r newstate
if echo "$newstate" | grep "int32 2"; then if echo "$newstate" | grep "int32 2"; then
touch /tmp/modem.locked.state touch /tmp/modem.locked.state

View file

@ -11,7 +11,7 @@ modem_n() {
} }
sim_n() { sim_n() {
SIMS="$(mmcli -m $(modem_n) | grep SIM)" SIMS="$(mmcli -m "$(modem_n)" | grep SIM)"
echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2 echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2
return return
} }
@ -23,11 +23,12 @@ else
pkill dmenu #kill existing dmenu pkill dmenu #kill existing dmenu
while [ $retry -eq 1 ]; do while [ $retry -eq 1 ]; do
PICKED="$( PICKED="$(
# shellcheck disable=SC2039
echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r " echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r "
)" )"
if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then
retry=0 retry=0
mmcli -i $(sim_n) --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1 mmcli -i "$(sim_n)" --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1
MSG=$(cat /tmp/unlockmsg) MSG=$(cat /tmp/unlockmsg)
[ -n "$MSG" ] && notify-send "$MSG" [ -n "$MSG" ] && notify-send "$MSG"
if echo "$MSG" | grep -q "not SIM-PIN locked"; then if echo "$MSG" | grep -q "not SIM-PIN locked"; then