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

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

hugomg opened this issue May 30, 2015 · 3 comments


Copy link

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.

Copy link

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

@ridiculousfish ridiculousfish added this to the fish-future milestone May 30, 2015
Copy link
Contributor Author

hugomg commented May 30, 2015

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

Copy link

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
develop7 pushed a commit to develop7/fish-shell that referenced this issue Apr 17, 2017
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 fish-shell#2106
@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.
None yet

Successfully merging a pull request may close this issue.

3 participants