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.
This commit is contained in:
Matt Smith 2025-07-03 20:41:17 -04:00 committed by GitHub
parent f13dc5b903
commit ff4eed08bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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