Deal with the device port containing unexpected whitespace

This should never happen, but could if something goes badly wrong
in the device detection code, e.g. someone changing it in a way
which caused extra output on STDOUT.
pull/304/head
Adam Spiers 7 years ago
parent 7bcae5f2d2
commit 084679d2d1

@ -249,13 +249,27 @@ reset_device() {
} }
check_device_port () { check_device_port () {
if [ -z $DEVICE_PORT ]; then if [ -z "$DEVICE_PORT" ]; then
echo "Couldn't autodetect the keyboard's serial port." cat <<EOF >&2
echo "If you see this message and your keyboard is connected to your computer," Couldn't autodetect the keyboard's serial port.
echo "it probably means that our serial port detection logic is buggy or incomplete." If you see this message and your keyboard is connected to your computer,
echo it probably means that our serial port detection logic is buggy or incomplete.
echo "Please report this issue at https://github.com/keyboardio/Kaleidoscope";
exit 0; Please report this issue at https://github.com/keyboardio/Kaleidoscope
EOF
exit 1
elif echo "$DEVICE_PORT" | grep -q '[[:space:]]'; then
cat <<EOF >&2
Unexpected whitespace found in detected serial port:
$DEVICE_PORT
If you see this message, it means that our serial port
detection logic is buggy or incomplete.
Please report this issue at https://github.com/keyboardio/Kaleidoscope
EOF
exit 1
fi fi
} }

Loading…
Cancel
Save