0

我有以下内容:

if [ $kernel == 'Darwin' ]; then
    $HOME="/Users/$user"
elif [ $kernel == 'Linux' ]; then
    $HOME="/home/$user"
fi

# Let the script know what the dotfiles dir is
dotfiles_dir="$HOME/dotfiles"

# Making symlinks to shell files, add yours as you need
echo 'Making symlinks to shell files'
ln -sfn -v $dotfiles_dir/shells/zsh $HOME/.zsh
ln -sfn -v $dotfiles_dir/shells/zsh/zshrc $HOME/.zshrc
ln -sfn -v $dotfiles_dir/shells/bash $HOME/.bash
ln -sfn -v $dotfiles_dir/shells/bash/bash_profile $HOME/.bash_profile
ln -sfn -v $dotfiles_dir/shells/bash/bashrc $HOME/.bashrc
ln -sfn -v $dotfiles_dir/shells/profile $HOME/.profile
echo "Done at [$time]...\n"

然而,这奇怪地输出:

[Other output here...]

Making symlinks shell files
/Users/eduan/.zsh -> /Users/eduan/dotfiles/shells/zsh
/Users/eduan/.zshrc -> /Users/eduan/dotfiles/shells/zsh/zshrc
/Users/eduan/.bash -> /Users/eduan/dotfiles/shells/bash
./bashrc -> /Users/eduan/dotfiles/shells/bash/bashrc
/Users/eduan/.profile -> /Users/eduan/dotfiles/shells/profile
Done at [08:15]...

[Other output here...]

谁能告诉我为什么我会得到这个意外的输出?我的其他符号链接生成正确,但是 Bash 符号链接由于某种原因被弄乱了。

顺便说一句,这是一个生成符号链接的大脚本。这只是其中的一部分,我把相关部分放在了上面,以免你感到困惑。:)

编辑:

这是脚本最新版本的链接:https ://github.com/Greduan/dotfiles/blob/master/scripts/make_symlinks.sh

4

2 回答 2

1

符号链接命令的 darwin 版本缺少 bashrc 的目标,因此转到当前目录。

我不确定为什么该脚本有两个版本?

此外,如果备份目录已经存在,您只创建它,这是不对的?

于 2013-01-10T14:42:18.830 回答
1

这条线是错误的,不是吗。缺少目标目录。

ln -sfn -v $dotfiles_dir/shells/bash/bashrc
于 2013-01-10T14:46:19.787 回答