completion: update SHELL for ngrok#22327
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts Homebrew’s generated shell completion logic to set SHELL as an absolute path (e.g., /bin/zsh) when invoking completion generators, to accommodate tools (like ngrok) that treat SHELL differently depending on whether it looks like a path.
Changes:
- Set
SHELLto/bin/<shell>when generating completions for both formulae and casks. - Update cask generated-completion specs to reflect the new
SHELLvalue format.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/formula.rb | Changes the SHELL env passed to completion generators to an absolute /bin/<shell> path. |
| Library/Homebrew/cask/artifact/generated_completion.rb | Applies the same SHELL env change for cask-generated completions. |
| Library/Homebrew/test/cask/artifact/generated_completion_spec.rb | Updates expectations/mocking to match the new SHELL env format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| shells.each do |shell| | ||
| popen_read_env = { "SHELL" => shell.to_s } | ||
| popen_read_env = { "SHELL" => "/bin/#{shell}" } | ||
| script_path = completion_script_path_map[shell] |
| shells.each do |shell| | ||
| popen_read_env = { "SHELL" => shell.to_s } | ||
| popen_read_env = { "SHELL" => "/bin/#{shell}" } | ||
| script_path = completion_script_path_map[shell] |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
This doesn't seem like the right fix. /bin/bash and /bin/zsh exist on macOS but may not on Linux and /bin/fish doesn't.
|
|
||
| expect(bash_dir/"foo").to be_a_file | ||
| expect((bash_dir/"foo").read).to eq("bash completion output") | ||
| expect((bash_dir/"foo").read).to eq("/bin/bash completion output") |
| expect((zsh_dir/"_foo").read).to eq("/bin/zsh completion output") | ||
| expect(fish_dir/"foo.fish").to be_a_file | ||
| expect((fish_dir/"foo.fish").read).to eq("fish completion output") | ||
| expect((fish_dir/"foo.fish").read).to eq("/bin/fish completion output") |
There was a problem hiding this comment.
Answered below, but we could set them to paths in homebrew's prefix if you think that makes more sense
Right, but this path doesn't need to exist here as it's only purpose is for the completion generator to infer what shell to generate for. Just as setting |
|
@branchv I don't think we should make a global completion change like this just for an |
brew lgtm(style, typechecking and tests) with your changes locally?ngrokcask appears to ignore $SHELL unless it looks like a pathI would send ngrok a PR instead, but it's closed source and is simple enough to support on our side