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

CDPATH should implicitly include $PWD/"." #4484

Closed
David-A-RogersHS2 opened this issue Oct 16, 2017 · 6 comments
Closed

CDPATH should implicitly include $PWD/"." #4484

David-A-RogersHS2 opened this issue Oct 16, 2017 · 6 comments

Comments

@David-A-RogersHS2
Copy link

@David-A-RogersHS2 David-A-RogersHS2 commented Oct 16, 2017

macOS Sierra/iterm

For testing purposes, I moved my fish directory elsewhere. If I set CDPATH to ~/mydirs, then if I am in my home dir, attempting to cd to any subdir fails. Note that ~/mydirs is empty at this point.

This terminal listing shows the issue.

Welcome to fish, the friendly interactive shell
david@Davids-MacBook-Pro ~> cd bin
david@Davids-MacBook-Pro ~/bin> ..
david@Davids-MacBook-Pro ~> set -x CDPATH /Users/david/mydirs/
david@Davids-MacBook-Pro ~> cd bin
cd: The directory 'bin' does not exist
david@Davids-MacBook-Pro ~> fish --version
fish, version 2.6.0
david@Davids-MacBook-Pro ~> echo $version
2.6.0
david@Davids-MacBook-Pro ~>

If I unset CDPATH, I can cd to subdirs of $HOME again.

I thought it might be something I did, but I removed my .config/fish directory and it still happens.

@David-A-RogersHS2
Copy link
Author

@David-A-RogersHS2 David-A-RogersHS2 commented Oct 17, 2017

I dunno if this will help, but here's the result of the set command.

Apple_PubSub_Socket_Render /private/tmp/com.apple.launchd.6wzCuNL3DS/Render
CMD_DURATION 0
COLORFGBG '7;0'
COLORTERM truecolor
COLUMNS 100
FISH_VERSION 2.6.0
HOME /Users/david
IFS \n\ \t
ITERM_PROFILE 'Default Fish'
ITERM_SESSION_ID w0t1p0:6BDE260C-2B97-4CA0-9078-47133A1B46DC
LANG en_US.UTF-8
LINES 50
LOGNAME david
PATH '/usr/local/bin'  '/usr/bin'  '/bin'  '/usr/sbin'  '/sbin'
PWD /Users/david
SHELL /bin/bash
SHLVL 1
SSH_AUTH_SOCK /private/tmp/com.apple.launchd.GEynqyiXD6/Listeners
TERM xterm-256color
TERM_PROGRAM iTerm.app
TERM_PROGRAM_VERSION 3.1.3
TERM_SESSION_ID w0t1p0:6BDE260C-2B97-4CA0-9078-47133A1B46DC
TMPDIR /var/folders/ky/6z5qfryx7sj5_4js_7skh9680000gn/T/
USER david
XPC_FLAGS 0x0
XPC_SERVICE_NAME 0
_ set
__CF_USER_TEXT_ENCODING 0x1F5:0x0:0x0
__fish_active_key_bindings fish_default_key_bindings
__fish_bin_dir /usr/local/Cellar/fish/2.6.0/bin
__fish_config_interactive_done
__fish_datadir /usr/local/Cellar/fish/2.6.0/share/fish
__fish_help_dir /usr/local/Cellar/fish/2.6.0/share/doc/fish
__fish_init_2_39_8
__fish_init_2_3_0
__fish_prompt_hostname Davids-MBP
__fish_sysconfdir /usr/local/Cellar/fish/2.6.0/etc/fish
fish_bind_mode default
fish_color_autosuggestion '555'  'brblack'
fish_color_cancel -r
fish_color_command --bold
fish_color_comment red
fish_color_cwd green
fish_color_cwd_root red
fish_color_end brmagenta
fish_color_error brred
fish_color_escape 'bryellow'  '--bold'
fish_color_history_current --bold
fish_color_host normal
fish_color_match --background=brblue
fish_color_normal normal
fish_color_operator bryellow
fish_color_param cyan
fish_color_quote yellow
fish_color_redirection brblue
fish_color_search_match 'bryellow'  '--background=brblack'
fish_color_selection 'white'  '--bold'  '--background=brblack'
fish_color_user brgreen
fish_color_valid_path --underline
fish_complete_path '/Users/david/.config/fish/completions'  '/usr/local/Cellar/fish'…
fish_function_path '/Users/david/.config/fish/functions'  '/usr/local/Cellar/fish/2'…
fish_greeting 'Welcome to fish, the friendly interactive shell'
fish_key_bindings fish_default_key_bindings
fish_pager_color_completion
fish_pager_color_description 'B3A06D'  'yellow'
fish_pager_color_prefix 'white'  '--bold'  '--underline'
fish_pager_color_progress 'brwhite'  '--background=cyan'
fish_term24bit 1
fish_user_abbreviations
history 'exit'  'll'  'rm -Rf fish'  'man rm'  'cd .config/'  'set'  'cd bin/'  'set -e CD'…
status 0
umask 0022
version 2.6.0

@faho
Copy link
Member

@faho faho commented Oct 17, 2017

The issue here is that, unlike bash, fish doesn't include "." implicitly in CDPATH - if you set it, only those directories will be used.

That's probably not the right way to do it, and should be changed.

We could either append or prepend it. Appending is what bash does, and has the advantage of being backwards-compatible - no currently working cd call will behave differently, only things that currently error out will go to a directory. On the other hand, I seem to like prepending - my CDPATH includes "." as the first element. It has the advantage of putting $PWD first - if you do ls, then you can cd to something you saw there without needing to use "./".

My $CDPATH setting is also why I erroneously added 1af38d6, which makes the completions behave as if "." was implicitly prepended.

Does anyone have any preferences?

@faho faho added this to the fish-3.0 milestone Oct 17, 2017
@faho faho changed the title Bug in CDPATH handling? CDPATH should implicitly include $PWD/"." Oct 17, 2017
@faho
Copy link
Member

@faho faho commented Oct 17, 2017

Note that currently, explicitly adding "." to $CDPATH will work around it.

E.g.

set -x CDPATH /Users/david/mydirs/ .

@David-A-RogersHS2
Copy link
Author

@David-A-RogersHS2 David-A-RogersHS2 commented Oct 17, 2017

Thank you so much! I couldn't imagine why no one else was having this problem.

As far as I'm concerned it doesn't have to be changed at all as long as it is documented that you always want to have . in your CDPATH.

@faho
Copy link
Member

@faho faho commented Oct 17, 2017

As far as I'm concerned it doesn't have to be changed at all as long as it is documented that you always want to have . in your CDPATH.

Well... if you always want to have it, then why not include it?

If there's no reason not to include it, then allowing you not to is allowing you to shoot yourself in the foot for no reason.

And, as I said, even bash doesn't allow you to not have it (at least as far as I can see).

@David-A-RogersHS2
Copy link
Author

@David-A-RogersHS2 David-A-RogersHS2 commented Oct 17, 2017

Hmm. Maybe add it if it's not already somewhere in the list. If you allow the user to specify it then they can decide whether to prepend or append.

faho added a commit that referenced this issue Oct 18, 2017
That's not what happens - I had set CDPATH to start with ".".

See #4484.

This reverts commit 1af38d6.
@ridiculousfish ridiculousfish removed this from the fish-3.0 milestone Feb 28, 2018
@ridiculousfish ridiculousfish added this to the fish-future milestone Feb 28, 2018
@faho faho removed this from the fish-future milestone Mar 26, 2019
@faho faho added this to the fish 3.1.0 milestone Mar 26, 2019
mfilenko added a commit to mfilenko/dotfiles that referenced this issue Feb 5, 2020
@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.
Projects
None yet
Development

No branches or pull requests

3 participants