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
shellenv: use PATH variable, fish_user_paths should remain universal #7215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! One suggested tweak. Thanks!
Library/Homebrew/cmd/shellenv.sh
Outdated
echo "set -g fish_user_paths \"$HOMEBREW_PREFIX/bin\" \"$HOMEBREW_PREFIX/sbin\" \$fish_user_paths;" | ||
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"$HOMEBREW_PREFIX/share/man\" \$MANPATH;" | ||
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"$HOMEBREW_PREFIX/share/info\" \$INFOPATH;" | ||
echo "contains \"$HOMEBREW_PREFIX/sbin\" \$PATH; or set -gx PATH \"$HOMEBREW_PREFIX/sbin\" \$PATH;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we kill the contains
? We don't do that for anything else and it seems overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not overkill, it should be done for the rest as well.
Fish loads its config always, whether login or not, interactive or not. That means this could easily result in growing $*PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MikeMcQuaid, I didn't want to modify the shellenv output too much and was planning to not use contains
, but discussion on the fish gitter led me to include it. As @faho explained the PATH variables will continue to grow if you open fish within fish, for example. Thanks for the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @faho explained the PATH variables will continue to grow if you open fish within fish, for example.
This also applies to Bash and ZSH and no-one has complained about this until this PR.
Can we scope this just to PATH
for now, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Scope is limited to PATH
variable for fish shell only.
Thanks so much for your first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @charego! |
brew style
with your changes locally?brew tests
with your changes locally?There are two ways to manipulate PATH in fish shell.
PATH
variable directlyfish_user_paths
variable, whose contents are automatically prepended toPATH
fish_user_paths
is supposed to be a universal variable.When you evaluate the output of shellenv,
fish_user_paths
is set as a global variable which shadows the universal variable. This is technically legal, but it goes against best practice and causes issues when the user wants to updatefish_user_paths
in the future.For this reason it makes sense that shellenv should output instructions to update the
PATH
variable directly instead of fiddling withfish_user_paths
.Reference: fish shell tutorial, $PATH section