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.
The text was updated successfully, but these errors were encountered:
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?
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.