fix(complete): skip unreadable files in fish shebang completion scan - #707
Conversation
The conf.d-sourced fish init script scans every executable on $PATH to detect a `usage` shebang, peek-reading the first 128 bytes of each file. Files that are executable but not readable by the current user (e.g. macOS's setuid-root sudo, or execute-only visudo) make fish's own redirection layer print a warning on every shell startup, since the read's stderr redirect doesn't cover that failure mode. Skip files we can't read before attempting the peek-read.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe fish completion init script's PATH scanning loop now skips files that are not readable before attempting to peek-read their contents for shebang detection, preventing fish redirection warnings on execute-only or setuid binaries during shell startup. ChangesFish completion readability fix
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryGuards the shebang peek-read in the generated fish init script with a
Confidence Score: 5/5This is a safe, single-line guard addition with no behavioral change for readable files. The change is a one-line fish conditional inserted at the right point in the loop — after the executability check, before the file redirection — so files that already pass the No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(complete): skip unreadable files in ..." | Re-trigger Greptile |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [usage](https://github.com/jdx/usage) | patch | `3.5.2` → `3.5.4` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jdx/usage (usage)</summary> ### [`v3.5.4`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#354---2026-07-06) [Compare Source](jdx/usage@v3.5.3...v3.5.4) ##### 🐛 Bug Fixes - **(complete)** skip unreadable files in fish shebang completion scan by [@​GrantD-ADSK](https://github.com/GrantD-ADSK) in [#​707](jdx/usage#707) ##### 🔍 Other Changes - Enable Entire for Codex by [@​jdx](https://github.com/jdx) in [#​695](jdx/usage#695) - Update sponsor references for jdx.dev by [@​jdx](https://github.com/jdx) in [#​702](jdx/usage#702) - use release backends for cargo tools by [@​jdx](https://github.com/jdx) in [#​709](jdx/usage#709) ##### 📦️ Dependency Updates - update jdx/mise-action action to v4.2.0 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​698](jdx/usage#698) - update rust-lang/crates-io-auth-action action to v1.0.5 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​697](jdx/usage#697) - update rust crate itertools to 0.15 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​699](jdx/usage#699) - update actions/checkout action to v7 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​700](jdx/usage#700) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​701](jdx/usage#701) - update zizmorcore/zizmor-action action to v0.5.7 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​704](jdx/usage#704) - update dependency cargo-binstall to v1.20.1 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​703](jdx/usage#703) - update rust crate tera to v2 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​705](jdx/usage#705) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​708](jdx/usage#708) ##### New Contributors - [@​GrantD-ADSK](https://github.com/GrantD-ADSK) made their first contribution in [#​707](jdx/usage#707) ### [`v3.5.3`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#353---2026-06-23) [Compare Source](jdx/usage@v3.5.2...v3.5.3) ##### 🐛 Bug Fixes - **(docs)** show negated flags in cli help by [@​jdx](https://github.com/jdx) in [#​694](jdx/usage#694) - **(zsh)** preserve options for default completion by [@​jdx](https://github.com/jdx) in [#​693](jdx/usage#693) ##### 📦️ Dependency Updates - update jdx/pr-closer action to v1.1.0 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​689](jdx/usage#689) - lock file maintenance lockfile maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​691](jdx/usage#691) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNTYuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI1Ni4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
Summary
usage g completion-init fish) scans every executable on$PATHto detect ausageshebang, peek-reading the first 128 bytes of each file.sudo, or execute-onlyvisudo) make fish's own redirection layer print a warning on every shell startup, since the existingread ... 2>/dev/nullonly silences thereadbuiltin's stderr, not fish's own redirection-setup warning.test -r $file; or continueguard alongside the existing executability check, so unreadable files are skipped before the peek-read is attempted.Fixes #706
Test plan
cargo test -p usage-lib --lib complete::fishpasses, snapshot updated viaINSTA_UPDATE=alwayscargo fmt --check -p usage-libclean~/.config/fish/conf.d/usage.fisheliminates the/usr/bin/sudo//usr/sbin/visudowarnings on new fish shells, withfish g completion-init fishoutput otherwise unchangedSummary by CodeRabbit
PATHentries during fish initialization.