是否有可能分叉符号链接?

是否有可能分叉符号链接?

我将配置文件(例如 .zshrc)放入 encfs 容器中。当我登录系统时,容器尚未挂载,因此符号链接处于悬空状态。有没有办法让符号链接指向两个位置,这样如果一个位置不存在,它就会使用另一个位置?

答案1

我认为这是不可能的,但还有另一种方法可以达到相同的效果(语法;也sh应该有效):zsh

if ! find -L /dir/of/file -mindepth 1 -maxdepth 1 -type l -name filename
then
    . /dir/of/file/filename
    break # Or exit, return or whatever is necessary to avoid processing the rest of the file
fi

换句话说,如果符号链接没有损坏,则使用它,否则继续使用此文件。

相关内容