refactor kaleidoscope-builder to make shellcheck happy

pull/764/head
Jesse Vincent 5 years ago
parent 16b2404ab9
commit 680aac9818
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -161,7 +161,7 @@ prompt_before_flashing () {
} }
flash () { flash () {
maybe_build maybe_build "$@"
# Check to see if we can see a keyboard bootloader port. # Check to see if we can see a keyboard bootloader port.
# If we -can-, then we should skip over the "reset to bootloader" thing # If we -can-, then we should skip over the "reset to bootloader" thing
@ -186,29 +186,38 @@ flash () {
} }
check_bootloader_port_and_flash () { check_bootloader_port () {
if [ -z "${DEVICE_PORT_BOOTLOADER}" ]; then if [ -z "${DEVICE_PORT_BOOTLOADER}" ]; then
echo "Unable to detect a keyboard in bootloader mode. You may need to hold the 'Prog' key or hit a reset button" echo "Unable to detect a keyboard in bootloader mode."
echo "You may need to hold a key or hit a reset button."
echo "Please check your keyboard's documentation"
return 1 return 1
fi fi
echo "Flashing your keyboard:" }
flash_over_usb check_bootloader_port_and_flash () {
if [ $? != 0 ]; then if ! check_bootloader_port; then
sleep 2 return 1
flash_over_usb
fi fi
echo "Flashing your keyboard:"
if [ $? = 0 ]; then # If the flash fails, try a second time
echo "Keyboard flashed successfully!" if ! flash_over_usb; then
elif [ "${ARDUINO_VERBOSE}" != "-verbose" ]; then sleep 2
echo "Something went wrong. You might want to try flashing again with the VERBOSE environment variable set" if ! flash_over_usb; then
exit -1 if [ "${ARDUINO_VERBOSE}" != "-verbose" ]; then
echo "Something went wrong."
echo "You might want to try flashing again with the VERBOSE environment variable set"
fi fi
return 1
fi
fi
echo "Keyboard flashed successfully!"
return 0
} }
flash_over_usb () { flash_over_usb () {
@ -222,7 +231,7 @@ flash_over_usb () {
-b57600 \ -b57600 \
"-Uflash:w:${HEX_FILE_PATH}:i" \ "-Uflash:w:${HEX_FILE_PATH}:i" \
2>&1 |grep -v ^avrdude | grep -v '^$' |grep -v '^ ' | grep -vi programmer 2>&1 |grep -v ^avrdude | grep -v '^$' |grep -v '^ ' | grep -vi programmer
return ${PIPESTATUS[0]} return "${PIPESTATUS[0]}"
else else
${AVRDUDE} \ ${AVRDUDE} \
-C "${AVRDUDE_CONF}" \ -C "${AVRDUDE_CONF}" \
@ -237,14 +246,14 @@ flash_over_usb () {
} }
flash_from_bootloader() { flash_from_bootloader() {
maybe_build maybe_build "$@"
prompt_before_flashing prompt_before_flashing
find_bootloader_ports find_bootloader_ports
check_bootloader_port_and_flash check_bootloader_port_and_flash
} }
program() { program() {
maybe_build maybe_build "$@"
prompt_before_flashing prompt_before_flashing
flash_with_programmer flash_with_programmer
} }
@ -283,7 +292,7 @@ hex_with_bootloader () {
maybe_build () { maybe_build () {
if [ ! -e "${HEX_FILE_PATH}" ]; then if [ ! -e "${HEX_FILE_PATH}" ]; then
build build "$@"
fi fi
} }

Loading…
Cancel
Save