Skip to content

fix(md2html): check curl exit status for network errors - #172

Merged
ekalinin merged 1 commit into
masterfrom
fix/network-error-check
Sep 28, 2026
Merged

ekalinin merged 1 commit into
masterfrom
fix/network-error-check

Conversation

@ekalinin

Copy link
Copy Markdown
Owner

Summary

For a local file or stdin, a network failure was not detected: gh-md-toc printed an
empty TOC and exited with code 0. With --insert the empty TOC replaced the existing
one in the file.

gh_toc_md2html checked $? after rm -f "${gh_file_md}~~", which 8daa73c ("Skip
headers if end marker is present") inserted between the curl call and the check. So
$? was the status of rm -f, always 0, and XXNetworkErrorXX was never returned.

  • gh-md-toc: save the curl exit status right after the call and check it instead
    of $?.
  • tests/tests.bats: new test Error for local file without network access. It sends
    curl through HTTPS_PROXY=http://127.0.0.1:9 (a closed port) and expects the
    "requires access to github API" message and a non-zero exit code.

Part of #167: this resolves the SC2181 warning.

Testing

@ekalinin
ekalinin merged commit e184841 into master Sep 28, 2026
1 check passed
@ekalinin
ekalinin deleted the fix/network-error-check branch September 28, 2026 20:13
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.

1 participant