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

Comments

Projects
None yet
4 participants
@azixMcAze
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

azixMcAze commented Jan 4, 2019

Thanks!

@faho faho referenced this issue Jan 12, 2019

Closed

fish 3.0.1? #5520

7 of 7 tasks complete

@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

share/config: Don't split /etc/paths entries on spaces
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

This comment has been minimized.

Copy link
Member

ridiculousfish commented Jan 22, 2019

Picked into 3.0.1 as 40f5dd2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.