I have a script that makes an environment using symlinks, and then calls a process that uses ../ to navagate to other parts of that environement. Unfortunately since it uses symlinks .. refers to the true parent and not the owner of the symlink.

My main constraint is that I can't change the script that's using ../.




                fakeA -> realDirA
                fakeB -> realDirB

And the childScript.sh uses /tmp/fakeParent/fakeA/../fakeB/someTarget, and I can't change childScript.sh but I have full control over fakeParent and what ever permissions I need.

  • not clear what the problem is. What is the working directory when ../someTarget is used? That determines what .. refers to, not whether something is a symlink or not. Commented Mar 7, 2023 at 22:27
  • Ah, that makes sense, I'm in /tmp/fakeParent/fakeA, but I'd expect that pwd is then actually /...realDirA/ so ../ is in the whatever above realDirA
    – Hovestar
    Commented Mar 7, 2023 at 22:40
  • If you cd /tmp/fakeParent/fakeA then you are actually in /.../realDirA, Are you trying to make ../someTarget get to /.../realDirB/someTarget? If so you probably don't want fakeA to be a symbolic link, you want it to be a directory full of symbolic links. As an aside, always worth reading doc.cat-v.org/plan_9/4th_edition/papers/lexnames
    – icarus
    Commented Mar 7, 2023 at 22:51
  • Thanks, I'll read really quick, I changed the question and the script to still run in /tmp/ but the .. in that jumps out of my /tmp and into the ... space.
    – Hovestar
    Commented Mar 7, 2023 at 22:53
  • I don't understand. "I'm in /tmp/fakeParent/fakeA" means "my working directory is /tmp/fakeParent/fakeA"; so .. refers to /tmp/fakeParent/; simple as that. Commented Mar 7, 2023 at 23:39


You must log in to answer this question.

Browse other questions tagged .