Browse Source

sync: add support for symlinks

Signed-off-by: Alejandro Mery <amery@geeks.cl>
master
Alejandro Mery 11 years ago
parent
commit
830cdc5244
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      sync2.sh

+ 5
- 3
sync2.sh

@ -5,13 +5,13 @@ err() { echo "E: $$: $*" >&2; }
FILES="$(pwd -P)" FILES="$(pwd -P)"
for x; do for x; do
if [ -L "$x" ]; then
err "$x: symlinks not supported"
elif [ -d "$x" ]; then
if [ -d "$x" ]; then
true # skip dirs true # skip dirs
elif [ -L "$HOME/$x" ]; then elif [ -L "$HOME/$x" ]; then
d0="$(readlink "$HOME/$x")" d0="$(readlink "$HOME/$x")"
d1="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')" d1="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
d1="$(readlink -f "$d1")"
if [ "$d0" != "$d1" ]; then if [ "$d0" != "$d1" ]; then
err "$x: relinking, was [$d0]" err "$x: relinking, was [$d0]"
ln -snf "$d1" "$HOME/$x" ln -snf "$d1" "$HOME/$x"
@ -26,9 +26,11 @@ for x; do
d="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')" d="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
if [ -e "$HOME/$x" ]; then if [ -e "$HOME/$x" ]; then
info "$x: importing changes and linking" info "$x: importing changes and linking"
rm "$d"
cp -a "$HOME/$x" "$d" cp -a "$HOME/$x" "$d"
else else
info "$x: linking" info "$x: linking"
d="$(readlink -f "$d")"
fi fi
ln -snf "$d" "$HOME/$x" ln -snf "$d" "$HOME/$x"
fi fi

Loading…
Cancel
Save