Skip to content

gmtwhich/gmtget: Report a failed download through the exit status - #9196

Closed
Esteban82 wants to merge 1 commit into
masterfrom
fix-9195
Closed

Esteban82 wants to merge 1 commit into
masterfrom
fix-9195

Conversation

@Esteban82

Copy link
Copy Markdown
Member

Proposes an answer to #9195: gmt which -G and gmt get -D now return GMT_FILE_NOT_FOUND (16) when a requested download didn't produce the file, instead of always exiting 0 — both already detected the miss for their error messages, just discarded it. Scoped to -G/-D only (plain gmt which <local file> is untouched), -C keeps exiting 0 since its job is reporting Y/N as text, and tiled dataset listings aren't covered. These are judgment calls, not answers from the issue thread — happy to adjust.

Tested with:

$ gmt which -Ga @earth_relief_01d_g @nonexistent.nc --GMT_AUTO_DOWNLOAD=off; echo "exit = $?"
...
/home/x/.gmt/static/server/earth/earth_relief/earth_relief_01d_g.grd
exit = 16

$ gmt get -Ddata=earth_mask -I1d --GMT_AUTO_DOWNLOAD=off; echo "exit = $?"
...
exit = 16

Fixes #9195

Assisted-by: Claude Sonnet 5

Both -G (gmtwhich) and -D (gmtget) already detect a missing file after
gmt_download_file_if_not_found() (the not-found message, and the error
lines it logs) but discarded that outcome and always returned
GMT_NOERROR. Track it instead and return GMT_FILE_NOT_FOUND when a
requested download did not produce the file. Scoped to -G/-D only (a
plain "gmt which localfile" is unaffected) and gmtwhich -C keeps
exiting 0, since its whole point is reporting Y/N as text. Tiled
dataset listings are not covered here.

Fixes #9195

Assisted-by: Claude Sonnet 5
@Esteban82
Esteban82 marked this pull request as draft September 11, 2026 01:21
@Esteban82

Copy link
Copy Markdown
Member Author

Closing — I created this PR without confirming first. Following up on the exit-status question in #9195 separately.

@Esteban82 Esteban82 closed this Sep 11, 2026
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.

Should "gmt which -G" and "gmt get -D" report failed downloads through their exit status?

1 participant