mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-20 16:11:14 -03:00
Don't resolve symlinks with cd
This switches fish to a "virtual" PWD, where it no longer uses getcwd to discover its PWD but instead synthesizes it based on normalizing cd against the $PWD variable. Both pwd and $PWD contain the virtual path. pwd is taught about -P to return the physical path, and -L the logical path (which is the default). Fixes #3350
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
- <a href='#faq-exported-uvar'>Why doesn't `set -Ux` (exported universal variables) seem to work?</a>
|
||||
- <a href='#faq-customize-colors'>How do I customize my syntax highlighting colors?</a>
|
||||
- <a href='#faq-update-manpage-completions'>How do I update man page completions?</a>
|
||||
- <a href='#faq-cwd-symlink'>Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?</a>
|
||||
- <a href='#faq-cd-implicit'>I accidentally entered a directory path and fish changed directory. What happened?</a>
|
||||
- <a href='#faq-open'>The open command doesn't work.</a>
|
||||
- <a href='#faq-default'>How do I make fish my default shell?</a>
|
||||
@@ -154,17 +153,6 @@ Use the web configuration tool, <a href="commands.html#fish_config">`fish_config
|
||||
|
||||
Use the <a href="commands.html#fish_update_completions">`fish_update_completions`</a> command.
|
||||
|
||||
<hr>
|
||||
\section faq-cwd-symlink Why does cd, $PWD and and various fish commands always resolve symlinked directories to their canonical path?
|
||||
|
||||
<i>For example if `~/images` is a symlink to `~/Documents/Images`, if I write '`cd images`', my prompt will say `~/Documents/Images`, not `~/images`.</i>
|
||||
|
||||
Because it is impossible to consistently keep symlinked directories unresolved. It is indeed possible to do this partially, and many other shells do so. But it was felt there are enough serious corner cases that this is a bad idea. Most such issues have to do with how '..' is handled, and are variations of the following example:
|
||||
|
||||
Writing `cd images; ls ..` given the above directory structure would list the contents of `~/Documents`, not of `~`, even though using `cd ..` changes the current directory to `~`, and the prompt, the `pwd` builtin and many other directory information sources suggest that the current directory is `~/images` and its parent is `~`. This issue is not possible to fix without either making every single command into a builtin, breaking Unix semantics or implementing kludges in every single command. This issue can also be seen when doing IO redirection.
|
||||
|
||||
Another related issue is that many programs that operate on recursive directory trees, like the find command, silently ignore symlinked directories. For example, ```find $PWD -name '*.txt'``` silently fails in shells that don't resolve symlinked paths.
|
||||
|
||||
<hr>
|
||||
\section faq-cd-implicit I accidentally entered a directory path and fish changed directory. What happened?
|
||||
|
||||
|
||||
@@ -9,4 +9,8 @@ pwd
|
||||
|
||||
`pwd` outputs (prints) the current working directory.
|
||||
|
||||
Note that `fish` always resolves symbolic links in the current directory path.
|
||||
The following options are available:
|
||||
|
||||
- `-L`, Output the logical working directory, without resolving symlinks (default behavior).
|
||||
|
||||
- `-P`, Output the physical working directory, with symlinks resolved.
|
||||
|
||||
Reference in New Issue
Block a user