In my home directory /home/regis, after creating a symbolic link LINK to directory DIR/SUBDIR, and doing cd LINK, I have a conflict between bash and its auto-completer regarding what .. leads to.
For bash auto-completer, .. leads to /home/regis, as the user expects since pwd displays /home/regis/LINK, just like the prompt does with PS1 using \w.
For bash itself, .. leads to DIR and ../.. leads to /home/regis, which means it's using the real path /home/regis/DIR/SUBDIR, as displayed by pwd -P.
Which behaviour should be expected here? Am I doing something wrong here?
/home/regis$ touch FILE /home/regis$ mkdir -p DIR/SUBDIR /home/regis$ ln -s DIR/SUBDIR LINK /home/regis$ cd LINK/home/regis/LINK$ ls ../FI # autocomplete with TAB succeeds here /home/regis/LINK$ ls ../FILE # but autocompleted command will fail here ls: cannot access '../FILE': No such file or directory /home/regis/LINK$ ls ../../FILE # command succeeds FILE
$ bash -version GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
lsfrom the equation by doingchmod +x FILEand tried to autocomplete it aftercd LINKwith../FI [TAB]and tried to execute it with../FILEto see what happens.Both autocomplete and execution failed, so at least autocomplete is not misleading in this case. But I guess it's because something like
– Regis Apr 26 '23 at 16:09statandsh -care involved, with the same issue asls.../FILEback "through" the symlink when executing if it wanted to. Looks like it doesn't, I don't know if there's some particular issue that it could cause – ilkkachu Apr 26 '23 at 17:07