docs: guard timeout for portability, validate capability-probe output - #40
Merged
Conversation
`timeout` is GNU coreutils and absent from a stock macOS, so a hard-coded `timeout 2 <tool> --version` fails outright with "command not found" and yields empty output; wrapped in the usual `|| true`, that reads downstream as "the tool produced nothing". Symptom: a step green on ubuntu-latest, failing on macos-latest with the tool reported absent. Document a run_bounded helper (timeout → gtimeout → unbounded), noting that `</dev/null` is what actually prevents the common hang and is portable. Also document validating the shape of a capability probe's output: a tool that does not recognise the subcommand may treat the probe words as arguments and do real work — `bandit complete bash` runs a scan, exits 0, and prints output containing "complete". And confirm the result refers to the tool probed, since a wrapper can return its host's answer (`rga --generate complete-bash` returns ripgrep's script verbatim). Came from /retro: yes Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Two gotchas hit while auto-detecting bash-completion support across ~112 CLI tools.
1.
timeoutis not portabletimeoutis GNU coreutils; a stock macOS does not ship it. A hard-codedtimeout 30 <tool> …therefore fails withtimeout: command not foundand producesempty output — and wrapped in the usual
|| true/2>/dev/null, that failure issilent, so every downstream check reads "the tool produced nothing" instead of "the
guard is missing".
Concretely: this passed on
ubuntu-latestand failed onmacos-latest, where everyprobed tool looked incapable. Documents a
run_boundedhelper (timeout→gtimeout→ unbounded), and notes that
</dev/null— not the timeout — is what actually preventsthe common hang, and is portable.
2. Validate the shape of a capability probe's output
Detecting support by running the tool has a failure mode beyond "non-zero exit" and
"empty output": a tool that doesn't recognise the subcommand may treat the probe words
as arguments and do real work.
bandit complete bashruns a security scan overpaths named
complete/bash, exits 0, and prints a report containing the word"complete" — passing any keyword grep.
Adds three rules: require a real registration (
complete -…/compgen/COMPREPLY),probe from a scratch dir with stdin detached, and confirm the output refers to the tool
you probed — a wrapper can return its host's answer (
rga --generate complete-bashreturns ripgrep's script verbatim; a
ghextension'scompletionemitsgh's own).Follow-up, not in this PR
Four shipped installers use bare
timeoutfor version detection and so hit item 1 onmacOS (version reported as
<none>):installers/package_manager.sh,uv_tool.sh,github_release_binary.sh,npm_self_update.sh. Fixing them properly means a shared helper inscripts/lib/plus all four call sites — worth doing as its own change, and I can't exercise macOS
here to verify it. Flagging rather than folding a partly-untestable installer refactor
into a docs PR.
Came from /retro: yes