improve symlink function
This commit is contained in:
parent
bf4ddbba24
commit
74ba4615d1
16
install.sh
16
install.sh
@ -27,23 +27,23 @@ function symlink() {
|
||||
src=$1
|
||||
dest=$2
|
||||
|
||||
if [ -e $dest ]; then
|
||||
if [ -L $dest ]; then
|
||||
if [ -e "${dest}" ]; then
|
||||
if [ -L "${dest}" ]; then
|
||||
# Already symlinked -- I'll assume correctly.
|
||||
return
|
||||
else
|
||||
# Rename files with a ".old" extension.
|
||||
echo "$dest already exists, renaming to $dest.old"
|
||||
backup=$dest.old
|
||||
if [ -e $backup ]; then
|
||||
echo "${dest} already exists, renaming to ${dest}.old"
|
||||
backup="${dest}.old"
|
||||
if [ -e "${backup}" ]; then
|
||||
echo "Error: $backup already exists. Please delete or rename it."
|
||||
exit 1
|
||||
fi
|
||||
mv -v $dest $backup
|
||||
mv -v "${dest}" "${backup}"
|
||||
fi
|
||||
fi
|
||||
echo "Linking $(basename $src)..."
|
||||
ln -sf $src $dest
|
||||
echo "Linking $(basename "${src}")..."
|
||||
ln -sf "${src}" "${dest}"
|
||||
}
|
||||
|
||||
read -p "Press enter to install dotfiles " WAIT_FOR_INPUT
|
||||
|
Loading…
Reference in New Issue
Block a user