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

Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- The `man` completions won't interpret the argument as a regex anymore. (#5566)
- Killing the terminal while fish is in vi-normal mode will no longer send it spinning and eating CPU. (#5528)
- `brew.fish`: Add `update-reset` subcommand completion
- The `path_helper` on macOS now only runs in login shells, matching the bash implementation.


# fish 3.0.0 (released December 28, 2018)
Expand Down
68 changes: 34 additions & 34 deletions share/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -186,47 +186,47 @@ if not set -q __fish_init_2_3_0
set -U __fish_init_2_3_0
end

# macOS-ism: Emulate calling path_helper.
if command -sq /usr/libexec/path_helper
# Adapt construct_path from the macOS /usr/libexec/path_helper
# executable for fish; see
# https://opensource.apple.com/source/shell_cmds/shell_cmds-203/path_helper/path_helper.c.auto.html .
function __fish_macos_set_env -d "set an environment variable like path_helper does (macOS only)"
set -l result

for path_file in $argv[2] $argv[3]/*
if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
end
end

for entry in $$argv[1]
if not contains $entry $result
set result $result $entry
end
end

set -xg $argv[1] $result
end

__fish_macos_set_env 'PATH' '/etc/paths' '/etc/paths.d'
if [ -n "$MANPATH" ]
__fish_macos_set_env 'MANPATH' '/etc/manpaths' '/etc/manpaths.d'
end
functions -e __fish_macos_set_env
end


#
# Some things should only be done for login terminals
# This used to be in etc/config.fish - keep it here to keep the semantics
#

if status --is-login
# macOS-ism: Emulate calling path_helper.
if command -sq /usr/libexec/path_helper
# Adapt construct_path from the macOS /usr/libexec/path_helper
# executable for fish; see
# https://opensource.apple.com/source/shell_cmds/shell_cmds-203/path_helper/path_helper.c.auto.html .
function __fish_macos_set_env -d "set an environment variable like path_helper does (macOS only)"
set -l result

for path_file in $argv[2] $argv[3]/*
if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
end
end

for entry in $$argv[1]
if not contains $entry $result
set result $result $entry
end
end

set -xg $argv[1] $result
end

__fish_macos_set_env 'PATH' '/etc/paths' '/etc/paths.d'
if [ -n "$MANPATH" ]
__fish_macos_set_env 'MANPATH' '/etc/manpaths' '/etc/manpaths.d'
end
functions -e __fish_macos_set_env
end

#
# Put linux consoles in unicode mode.
#
Expand Down