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

/etc/paths.d entries are split when containing spaces #5481

Closed
azixMcAze opened this issue Jan 4, 2019 · 3 comments
Closed

/etc/paths.d entries are split when containing spaces #5481

azixMcAze opened this issue Jan 4, 2019 · 3 comments
Labels
Milestone

Comments

@azixMcAze
Copy link

@azixMcAze azixMcAze commented Jan 4, 2019

Hi!
I am using Fish 3.0.0 on macOS 10.13.6

$ fish --version
fish, version 3.0.0
$ echo $version
3.0.0

I have added an entry in /etc/paths.d/ that contains a space in its path:

$ cat /etc/paths.d/jre 
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin

This path is split on space when it is added to $PATH:

Welcome to fish, the friendly interactive shell
$ echo $version
3.0.0
$ for p in $PATH; echo $p; end
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin

However, this was not the case with fish 2.7.1:

Welcome to fish, the friendly interactive shell
$ echo $version
2.7.1
$ for p in $PATH; echo $p; end
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin

path_helper does not split the entries on spaces:

$ /usr/libexec/path_helper
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin"; export PATH;

I have opened a new terminal tab for each test so I think fish did not inherit a previous session's env vars.

@faho
Copy link
Member

@faho faho commented Jan 4, 2019

Indeed.

The code responsible:

while read -la entry
    if not contains $entry $result
        set result $result $entry
    end
end <$path_file

And the character responsible for this: "a". read -la entry reads to the next newline, and splits the line into the variable "entry" on spaces and tabs.

@faho faho added the bug label Jan 4, 2019
@faho faho added this to the fish 3.1.0 milestone Jan 4, 2019
@faho faho closed this in 04f1ea0 Jan 4, 2019
@azixMcAze
Copy link
Author

@azixMcAze azixMcAze commented Jan 4, 2019

Thanks!

@faho faho mentioned this issue Jan 12, 2019
7 tasks done
@zanchey zanchey modified the milestones: fish 3.1.0, fish 3.0.1 Jan 18, 2019
ridiculousfish added a commit that referenced this issue Jan 21, 2019
This used `read -la`, which _splits_.

Instead, don't do that, each line is its own entry.

Fixes #5481.

[ci skip]
ridiculousfish added a commit that referenced this issue Jan 21, 2019
@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Jan 22, 2019

Picked into 3.0.1 as 40f5dd2

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants