Repository navigation
fix(zsh): which is a builtin in zsh mode, so Esc Esc stops erroring - #181
Merged
Merged
Conversation
oh-my-zsh's sudo widget runs `builtin which -a "$cmd"` on every Esc Esc once $EDITOR is set, and hellish had no `which` builtin: each toggle printed "builtin: which: not a shell builtin" over the prompt, and an editor reached only through that check (`vim f` with EDITOR set to a second vim on $PATH) became `sudo vim f` instead of `sudo -e f`. `which [-ap] name...` is zsh's (whence -c): alias, reserved word, function, builtin, then the command; -a lists every match, -p paths only; "NAME not found" on stdout and status 1, as zsh. Diffed against zsh 5.8.1 on 20 invocations: identical apart from the error prefix. It resolves in zsh mode only. `which` is also /usr/bin/which, and a bash script's `which`, `type which` and `command -v which` must keep meaning that one, so it sits in a separate table that builtin_func() consults only under zsh_mode(). builtin_func() now takes the shell state for that; every caller already had it, and the compiler found them all. declare -f's body trimming moves to func_text_trimmed() so `which` prints a function with the same text. Caveats in the code: functions print as written rather than deparsed; the reserved words are the POSIX set. tests/omz_sudo_widget_test.py adds the second-vim case and fails on "not a shell builtin" anywhere: 2 failed before, 11 ok after. Golden suite 5363/5363; zsh_builtins, zle and plugin_corpus tests pass. wiki/builtins regenerated (it also picks up `bind`, which was missing).
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.
oh-my-zsh's sudo widget runs
builtin which -aon every Esc Esc (with$EDITORset). hellish had no such builtin: every toggle printedbuiltin: which: not a shell builtin, andvim fwith$EDITOR= a second vim on$PATHbecamesudo vim finstead ofsudo -e f.which [-ap] name...= zsh'swhence -c; diffed against zsh 5.8.1 on 20 invocations — identical except the error prefix.builtin_func()underzsh_mode(), so bash scripts keep/usr/bin/which(type which,command -v whichunchanged).builtin_func()now takes the shell state; every caller had it.omz_sudo_widget_test.py: new second-vim case + no "not a shell builtin" anywhere — 2 failed before, 11 ok after. Golden 5363/5363; zsh_builtins, zle, plugin_corpus pass.wiki/builtinsregenerated (also adds the missingbind).🤖 Generated with Claude Code