Skip to content

Commit 30fac3d

Browse files
janschescottleibrand
authored andcommitted
Prevent Nightscout from crashing if {} returned (#24)
Added one line to check content of $RESPONSE for emptyness (=~ {}) and unset $RESPONSE, so error checking through OR in next line applies.
1 parent 9896770 commit 30fac3d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

scripts/getvoltage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
command -v socat >/dev/null 2>&1 || { echo >&2 "I require socat but it's not installed. Aborting."; exit 1; }
44

5+
[[ $RESPONSE == "{}" ]] && unset RESPONSE
56
RESPONSE=`echo '{"command":"read_voltage"}' | socat -,ignoreeof ~/src/openaps-menu/socket-server.sock | sed -n 's/.*"response":\([^}]*\)}/\1/p'`
67
[[ $RESPONSE = *[![:space:]]* ]] && echo $RESPONSE
78
#./getvoltage.sh | sed -n 's/.*"response":\([^}]*\)}/\1/p'

0 commit comments

Comments
 (0)