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
|
src=$1
|
||||||
dest=$2
|
dest=$2
|
||||||
|
|
||||||
if [ -e $dest ]; then
|
if [ -e "${dest}" ]; then
|
||||||
if [ -L $dest ]; then
|
if [ -L "${dest}" ]; then
|
||||||
# Already symlinked -- I'll assume correctly.
|
# Already symlinked -- I'll assume correctly.
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
# Rename files with a ".old" extension.
|
# Rename files with a ".old" extension.
|
||||||
echo "$dest already exists, renaming to $dest.old"
|
echo "${dest} already exists, renaming to ${dest}.old"
|
||||||
backup=$dest.old
|
backup="${dest}.old"
|
||||||
if [ -e $backup ]; then
|
if [ -e "${backup}" ]; then
|
||||||
echo "Error: $backup already exists. Please delete or rename it."
|
echo "Error: $backup already exists. Please delete or rename it."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mv -v $dest $backup
|
mv -v "${dest}" "${backup}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Linking $(basename $src)..."
|
echo "Linking $(basename "${src}")..."
|
||||||
ln -sf $src $dest
|
ln -sf "${src}" "${dest}"
|
||||||
}
|
}
|
||||||
|
|
||||||
read -p "Press enter to install dotfiles " WAIT_FOR_INPUT
|
read -p "Press enter to install dotfiles " WAIT_FOR_INPUT
|
||||||
|
Loading…
Reference in New Issue
Block a user