mirror of
https://git.dodsorf.as/Dandellion/dotfiles.git
synced 2024-12-27 21:17:30 +01:00
19 lines
402 B
Bash
Executable File
19 lines
402 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
for link; do
|
|
test -h "$link" || continue
|
|
|
|
dir=$(dirname "$link")
|
|
reltarget=$(readlink "$link")
|
|
case $reltarget in
|
|
/*) abstarget=$reltarget;;
|
|
*) abstarget=$dir/$reltarget;;
|
|
esac
|
|
|
|
rm -fv "$link"
|
|
cp -afv "$abstarget" "$link" || {
|
|
# on failure, restore the symlink
|
|
rm -rfv "$link"
|
|
ln -sfv "$reltarget" "$link"
|
|
}
|
|
done |