Skip to content

chirpc: Fix exit code on successful --download-mmap and --upload-mmap - #1572

Open
eflowkram wants to merge 1 commit into
kk7ds:masterfrom
eflowkram:fix/chirpc-exit-codes
Open

eflowkram wants to merge 1 commit into
kk7ds:masterfrom
eflowkram:fix/chirpc-exit-codes

Conversation

@eflowkram

Copy link
Copy Markdown
Contributor

Summary

sys.exit(1) was called unconditionally after the try/except block in both the --download-mmap and --upload-mmap paths, returning failure even when the operation succeeded. Any script checking the exit code would treat a successful clone as an error.

Fix: move sys.exit(1) inside the except block and add sys.exit(0) on success.

Steps to reproduce

python -m chirp.cli.main --radio Yaesu_FT-65R \
  --serial /dev/ttyUSB0 --mmap ft65.img --download-mmap
echo $?   # prints 1 even on success

Test plan

  • Successful --download-mmap exits with code 0
  • Successful --upload-mmap exits with code 0
  • Failed download/upload (e.g. wrong port) still exits with code 1

sys.exit(1) was called unconditionally after the try/except block in
both the download and upload paths, returning failure even when the
operation succeeded. Move sys.exit(1) inside the except block and add
sys.exit(0) on success.
@eflowkram
eflowkram force-pushed the fix/chirpc-exit-codes branch from ffcd6b0 to cde8745 Compare May 3, 2026 01:11
Comment thread chirp/cli/main.py
radio.sync_in()
radio.save_mmap(options.mmap)
LOG.info("Download successful: %s", options.mmap)
sys.exit(0)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to not exit(0) anywhere and take that default if we fall out the bottom with nothing failing. Just moving the exit(1) into the exception handler would take care of that. That would solve the problem right?

Really, sys.exit() anywhere in the middle of something is a bad pattern (this code is super old) but especially forcing exit success in the middle is pretty weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants