This sort of situation often occurs under the /sys/bus tree (bash-5.1) :
Let's say I get some foo directory listing several symlinks to other directories, ls -ails pathto_foo displaying something of the kind :
lrwxrwxrwx 1 root root 0 21 foo1 -> whatever relative path to symlinked foo1
lrwxrwxrwx 1 root root 0 21 foo2 -> whatever relative path to symlinked foo2
Each one of these symlinked dirs containing a regular file named bar :
If I change my present working directory to pathto_foo/foo1 or pathto_foo/foo2, I can file, stat, cat… bar without trouble.
However, my pwd being set to pathto-foo/foo1 (or pathto_foo/foo2), sat-ing/c-ating/file-ing ../foo2/bar (../foo1/bar respectively) will systematically return :
../foox/bar : No such file or directory
OK! I can, at some extreme limit understand and accept this utmost unwelcome behaviour, however, I just neither understand nor accept the following inconsistency :
If, sitting in anyone of those two directories, let's take pathto_foo/foo1, I want to stat/cat/file ../foo1/bar (yes! I do mean a relative path to the pwd) I'll be successful.
So why does the path resolution depend on the pwd ? (why are relative paths to the pwd resolved differently to other similarily written relative paths ?)
How can I prevent that and get an identical answer (successful or unsuccessful) irrespective of the pwd ?