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 () {
if [ -z $DEVICE_PORT ]; then
echo "Couldn't autodetect the keyboard's serial port."
echo "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
echo "Please report this issue at https://github.com/keyboardio/Kaleidoscope";
exit 0;
if [ -z "$DEVICE_PORT" ]; then
cat <<EOF >&2
Couldn't autodetect the keyboard's serial port.
If you see this message and your keyboard is connected to your computer,
it probably means that our serial port detection logic is buggy or incomplete.
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
}

Loading…
Cancel
Save