On Okt 31 2026, Bored Videos wrote:
> I found some strange behavior where ls thinks . is a directory, even if
> it's a symlink.
The current directory can never be a symlink. It is resolved before the
process enters it.
> Example:
>
> 0 17:45 ~ % mkdir original
> 0 17:45 ~ % ls -dl original
> drwxr-xr-x 2 s s 6 2026-10-31 17:45 original
> 0 17:45 ~ % ln -s original symlink-to-original
> 0 17:45 ~ % cd symlink-to-original
> 0 17:45 ~/symlink-to-original % rm -rf ../original
> 0 17:45 ~/symlink-to-original % ls -dl
> drwxr-xr-x 0 s s 6 2026-10-31 17:45 .
^
Note how the current directory is now an unlinked inode. It is the
directory formerly known as ~/original as its real name, and will
finally vanish once the shell has left it.
--
Andreas Schwab, [email protected]