You are not logged in.
Pages: 1
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
$ mkdir dir
$ ln -sf dir link2dir
$ builtin test -h link2dir && echo Link
$ Link
$ builtin test -d link2dir && echo Directory
$ Directory
I understand the "builtin test" dereferencing to the target "dir". Can I test a symbol link without dereferencing using pure bash?
I ended up using "realpath" instead.
Last edited by solskog (2025-03-02 04:29:38)
Offline
Sanity check, what's the problem here?
The file exists and is a link AND is a directory, this is the same behavior on /usr/bin/test and bash/zsh built-ins
Except for -h and -L, all FILE-related tests dereference symbolic links.
what makes sense since any other information about symlinks is close to pointless (maybe there's a case for checking their timewstamps, "find" is your friend here, though - but not pure bash)
Offline
except for -h and -L, all FILE-related tests dereference symbolic links.
You are right, I wasn't pay attention. I somehow answered my own question.
Last edited by solskog (2025-03-02 13:35:22)
Offline
Pages: 1