You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
736 B

13 years ago
13 years ago
13 years ago
  1. #!/bin/sh
  2. info() { echo "$$: $*"; }
  3. err() { echo "E: $$: $*" >&2; }
  4. FILES="$(pwd -P)"
  5. for x; do
  6. if [ -L "$x" ]; then
  7. err "$x: symlinks not supported"
  8. elif [ -d "$x" ]; then
  9. true # skip dirs
  10. elif [ -L "$HOME/$x" ]; then
  11. d0="$(readlink "$HOME/$x")"
  12. d1="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
  13. if [ "$d0" != "$d1" ]; then
  14. err "$x: relinking, was [$d0]"
  15. ln -snf "$d1" "$HOME/$x"
  16. fi
  17. else
  18. d="$(dirname "$x")"
  19. if [ ! -d "$HOME/$d/" ]; then
  20. info "$d: creating dir"
  21. mkdir -p "$HOME/$d/"
  22. fi
  23. d="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
  24. if [ -e "$HOME/$x" ]; then
  25. info "$x: importing changes and linking"
  26. cp -a "$HOME/$x" "$d"
  27. else
  28. info "$x: linking"
  29. fi
  30. ln -snf "$d" "$HOME/$x"
  31. fi
  32. done