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

Fish should treat an empty directory name in CDPATH as the current directory #2106

Closed
hugomg opened this Issue May 30, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@hugomg

hugomg commented May 30, 2015

In dash and bash, an empty directory name in CDPATH means the current working directory so setting CDPATH to :/ has the same meaning as setting it to .:/. Fish doesn't have this default though:

dash$ export CDPATH=":/"
dash$ cd Desktop      #this works
dash$ cd ..
dash$ fish # Now lets see what happens in fish
fish$ cd Desktop
cd: The directory “Desktop” does not exist

The motivation for me reporting this is that this problem is a bit similar to the problem in #2090. Other shells might append to the CDPATH using CDPATH=$CDPATH:/blah and that will leave a colon at the start if CDPATH is previously unset. In that case, when Fish breaks it down into an array the first element will be the empty string.

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish May 30, 2015

Member

Why do they do that? Argh. Thanks for reporting this.

Member

ridiculousfish commented May 30, 2015

Why do they do that? Argh. Thanks for reporting this.

@ridiculousfish ridiculousfish added this to the fish-future milestone May 30, 2015

@hugomg

This comment has been minimized.

Show comment
Hide comment
@hugomg

hugomg May 30, 2015

Yeah, that behavior is not in the manual... My guess is that its there so CDPATH=$CDPATH:/blah works

hugomg commented May 30, 2015

Yeah, that behavior is not in the manual... My guess is that its there so CDPATH=$CDPATH:/blah works

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Mar 17, 2017

Contributor

This is going to be slightly harder to fix than I initially thought. That's because the places which iterate over CDPATH use class wcstokenizer which ignores (i.e., does not return) empty fields. So set CDPATH '' /some/dir is equivalent to set CDPATH /some/dir. There are only five uses of wcstokenizer and at least three of them are wrong in light of this issue. So I'm leaning towards removing that class and switching all five uses to tokenize_variable_array(). There should not be two ways to tokenize a fish array from its string form to an actual array/vector. Thoughts, @ridiculousfish?

Contributor

krader1961 commented Mar 17, 2017

This is going to be slightly harder to fix than I initially thought. That's because the places which iterate over CDPATH use class wcstokenizer which ignores (i.e., does not return) empty fields. So set CDPATH '' /some/dir is equivalent to set CDPATH /some/dir. There are only five uses of wcstokenizer and at least three of them are wrong in light of this issue. So I'm leaning towards removing that class and switching all five uses to tokenize_variable_array(). There should not be two ways to tokenize a fish array from its string form to an actual array/vector. Thoughts, @ridiculousfish?

@krader1961 krader1961 modified the milestones: 2.6.0, fish-future Mar 17, 2017

krader1961 added a commit to krader1961/fish-shell that referenced this issue Mar 17, 2017

empty CDPATH elements are equivalent to "."
In the process of fixing the issue I decided it didn't make sense to
have two, incompatible, ways of converting variable strings to arrays.
Especially since the one I'm removing does not return empty array elements.

Fixes #2106

krader1961 added a commit to krader1961/fish-shell that referenced this issue Mar 17, 2017

empty CDPATH elements are equivalent to "."
In the process of fixing the issue I decided it didn't make sense to
have two, incompatible, ways of converting variable strings to arrays.
Especially since the one I'm removing does not return empty array elements.

Fixes #2106

develop7 added a commit to develop7/fish-shell that referenced this issue Apr 17, 2017

empty CDPATH elements are equivalent to "."
In the process of fixing the issue I decided it didn't make sense to
have two, incompatible, ways of converting variable strings to arrays.
Especially since the one I'm removing does not return empty array elements.

Fixes #2106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment