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

Only invoke path_helper in login shells #5637

Conversation

thefloweringash
Copy link
Contributor

@thefloweringash thefloweringash commented Feb 10, 2019

Matches upstream path_helper which is invoked in /etc/profile and only
applies to login shells. Enables running interactive, non-login shells
with altered PATH values.

Reverts change in c0f832a, which reverts change in adbaddf.

Description

The macOS path_helper prepends all system specified paths:

$ PATH=/foo /usr/libexec/path_helper -s
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/foo"; export PATH;

It's sometimes useful to run a shell with an altered path, for example to inject custom entries ahead of, or instead of, system entries. On bash this is possible since the path_helper is only run in a login shell:

$ PATH=/foo `which bash` -i -c 'echo $PATH'
/foo

$ PATH=/foo `which bash` -l -i -c 'echo $PATH'
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/foo

This makes fish behave equivalently.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

@faho faho requested a review from ridiculousfish Feb 10, 2019
@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Feb 11, 2019

Looks good, now it's justified :) Please update CHANGELOG.md

Matches upstream path_helper which is invoked in /etc/profile and only
applies to login shells. Enables running interactive, non-login shells
with altered PATH values.

Reverts change in c0f832a, which reverts change in adbaddf.
@thefloweringash
Copy link
Contributor Author

@thefloweringash thefloweringash commented Feb 11, 2019

Added a brief summary to the 3.0.1 fixes section.

@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Feb 13, 2019

merged as 56309f1, thanks!!

Note this is going into 3.1.0, not 3.0.1 (I updated the changelog appropriately)

@zanchey zanchey added this to the fish 3.1.0 milestone Feb 13, 2019
@thefloweringash thefloweringash deleted the path-helper-login-only branch Feb 14, 2019
fricklerhandwerk added a commit to fricklerhandwerk/.config that referenced this issue Oct 28, 2019
the script did not work on macOS because `fish` prepends the contents of
`/etc/paths` and `/etc/paths.d/*` to `$PATH` [1], resulting in BSD
`readlink` to be used instead of the one from `nixpkgs`. this is fixed
on the master branch [2], but the patch is staged for 3.1.0 (!), while
the most recent release is 3.0.2.

well, also the script was badly broken, I never ran it since changing it
the last time...

[1]: fish-shell/fish-shell#5456
[2]: fish-shell/fish-shell#5637
@archywillhe

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants