At least in bash, by default, the option
set +P is set, which makes certain commands like
pwd, and tab-completion follow the symbolic link hierarchy, rather than the physical hierarchy. But, lots of other commands, like
ls, just follow the physical hierarchy.
You can do
set -P to make all commands follow the physical directory structure (or add it to your
~/.inputrc file for permanence across sessions). But, what if I want to go the other way, to make all (most?) commands obey the symbolic directory structure? Can this be done? Is this bash-specific? Alternatively, is there a way to make things believe the symbolic directory is physical? And to be clear, I'm looking for a setting to affect behavior across all potential functions, not a workaround like
readlink. The closest I can find is this workaround.
For an example of how one can get unpleasant results, keep reading. This can lead to confusing behavior since you can tab-complete to a file/folder that the command you're running won't be able to find. For instance (you might have to do
set +P first):
mkdir symtest1 mkdir symtest1/subdir ln -s symtest1/subdir touch youreinthebasedir #a lovely file to show where you're looking touch symtest1/youreinsymtest1 #yet another pwd #shows where you are cd subdir pwd #should show the same plus "/subdir" ls ../ #should show the contents of "symtest1"
Now, type the following with tab-completion,
and it'll complete to
but hit enter, and you'll get an error that the file doesn't exist due to the aforementioned discrepancy.