1

clones is a link

nrolland at mactoasty in ~
$ la clones
lrwxr-xr-x  1 nrolland  staff    11B Oct  5 16:37 clones -> Sync/clones

from a subdirectory

nrolland at mactoasty in ~/clones/monoidAsComputation/app

$ ls ../../../

list all the files in ~/Sync

whereas this lists all the files in ~

cd ../../../; ls

If I try to point a symbolic link to a location above, that fails although I can cd into relative location

nrolland at mactoasty in ~/clones/monoidAsComputation/app
$ ln -s ../../../.emacs.d/reveal.js

whereas this will, because ln expands the clones symbolic link to its definition............

nrolland at mactoasty in ~/clones/monoidAsComputation/app
$ ln -s ../../../../.emacs.d/reveal.js

Is there any way to get back some sane referential transparency, or at least the same behavior between cd and ln ?


I use zsh, on macos. I will try with other shells

nicolas
  • 9,549
  • 3
  • 39
  • 83

1 Answers1

1

Not sure about zsh, but the following will work for bash:

To get the same behaviour as ln (and any other command), you can use cd -P in bash. In your example, you should see:

# nrolland at mactoasty in ~/clones/monoidAsComputation/app
cd -P ../../..; ls

listing files in ~/Sync, same as ls ../../../ does. You can get this behaviour with simple cd ../../.., by aliasing:

alias cd='cd -P'

For more information, see this answer.

Community
  • 1
  • 1
Jerzy
  • 670
  • 6
  • 12