From ff4eed08bcb5c0f99fbb8fbcd443d3896e08547a Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Thu, 3 Jul 2025 20:41:17 -0400 Subject: [PATCH] Fixed --change-mode option since it was broken (#7144) getopts can't parse double-dash options so it had to be done separately. Also fixed where CHANGE_MODE was checked since it wasn't working either. --- bin/device-update.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/device-update.sh b/bin/device-update.sh index 6adfe4e0e..2a39cdef7 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -30,6 +30,18 @@ Flash image file to device, leave existing system intact." EOF } +# Check for --change-mode and remove it from arguments +NEW_ARGS="" +for arg in "$@"; do + if [ "$arg" = "--change-mode" ]; then + CHANGE_MODE=true + else + NEW_ARGS="$NEW_ARGS \"\$arg\"" + fi +done + +# Reset positional parameters to filtered list +eval set -- $NEW_ARGS while getopts ":hp:P:f:" opt; do case "${opt}" in @@ -43,9 +55,6 @@ while getopts ":hp:P:f:" opt; do ;; f) FILENAME=${OPTARG} ;; - --change-mode) - CHANGE_MODE=true - ;; *) echo "Invalid flag." show_help >&2 @@ -55,7 +64,7 @@ while getopts ":hp:P:f:" opt; do done shift "$((OPTIND-1))" -if [[ $CHANGE_MODE == true ]]; then +if [ "$CHANGE_MODE" = true ]; then $ESPTOOL_CMD --baud 1200 --after no_reset read_flash_status exit 0 fi