Good day, ladies and gentlemen!
I noticed that a symlinked script of mine was resolving $PWD to the real path, so I did an experiment. I made a script having this code:
#!/bin/bash
tmpfile=$(mktemp --suffix=.tmpfile)
trap 'rm -f "$tmpfile"' EXIT
printf '
PWD: %s
pwd: %s
pwd -P: %s
' "$PWD" "$( pwd )" "$( pwd -P )" > "$tmpfile"
subl "$tmpfile"
Essentially, it creates a temporary file, writes pwd values in it and opens it in Sublime Text.
Incidentally, I discovered that while Sublime Text, Textadept, and Featherpad have no issues, Kate is not able to open the temporary file, maybe because it detects its removal. But I do not use Kate, I was just attempting to remain in the KDE ecosystem for the experiment.
Then I made both a copy and a symlink of the script and placed them in a symlinked folder.
It turned out that both the copy and the symlink behave the same way.
Then, when I open a Konsole window inside the /media/do/tmp/.tmp symlinked folder and run either of them, I get the expected
PWD: /media/do/tmp/.tmp
pwd: /media/do/tmp/.tmp
pwd -P: /media/dev/tmp
i.e. the real path only when asked specifically for it (/media/dev/tmp is the real path).
When I open a Dolphin window in the /media/do/tmp/.tmp symlinked folder and double-click either of them I get
PWD: /media/dev/tmp
pwd: /media/dev/tmp
pwd -P: /media/dev/tmp
i.e. the real path regardless of being requested for.
My questions:
- Is it happening because I am doing/setting up something wrong?
- Is there a way to get the CLI behaviour (not following the symlink unless asked) when launching a script in Dolphin?
Thank you for your time and patience!