Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use recommended way of updating Fish shell $PATH #11349

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/test/utils/shell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
ENV["SHELL"] = "/usr/local/bin/fish"
ENV["fish_user_paths"] = "/some/path"
expect(described_class.prepend_path_in_profile(path))
.to eq("echo 'set -g fish_user_paths \"#{path}\" $fish_user_paths' >> #{shell_profile}")
.to eq("echo 'fish_add_path #{path}' >> #{shell_profile}")
end
end
end
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def prepend_path_in_profile(path)
when :csh, :tcsh
"echo 'setenv PATH #{csh_quote(path)}:$PATH' >> #{profile}"
when :fish
"echo 'set -g fish_user_paths \"#{sh_quote(path)}\" $fish_user_paths' >> #{profile}"
"echo 'fish_add_path #{sh_quote(path)}' >> #{profile}"
Copy link
Contributor Author

@davidxia davidxia May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was only added in fish 3.2.0 [1] (also see #8965 (comment)). Is there a utility function we can use to get the version of the shell? I don't see anything for version here [2].

1: https://github.com/fish-shell/fish-shell/releases/tag/3.2.1
2: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/shell.rb#

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @MikeMcQuaid if you have any idea 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various shells have env vars that indicate their version [3]. Would it be worth adding (in another PR) a method in utils/shell.rb [4] called preferred_version that tries to return the user's preferred shell's version and nil if it can't be determined?

3: https://stackoverflow.com/a/38240328/553994
4: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/shell.rb

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if it works in the latest stable brew install fish that's sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked PR as ready for review. PTAL thanks!

end
end

Expand Down