Permalink
Browse files

Now with newer-file protection

  • Loading branch information...
1 parent 3b30564 commit 99c0a7be43719e550f9dab2b0ff0e455e95a834b @twooster committed Mar 13, 2012
Showing with 22 additions and 14 deletions.
  1. +22 −14 install.sh
View
@@ -6,23 +6,31 @@
# -r raw mode, ignoring backslashes
./refresh.sh
-while IFS= read -r file; do
+while IFS= read -r file <&3; do
# get basename by trimming longest */ at beginning
base="${file##*/}"
# get directory name by trimming basename
dir="${file%"$base"}"
# trim trailing slash for pretties
dir="${dir%/}"
- dirto="$HOME/$dir"
- if [[ ! -d "$dirto" ]]; then
- echo Making directory $dirto...
- mkdir -p "$dirto"
- fi
- if [[ "$HOME/$file" -nt "$prefix/$file" ]]; then
- echo "Destination file appears to be newer, please confirm copy:"
- cp -ip "$prefix/$file" "$HOME/$file"
- else
- echo Copying to $HOME/$file
- cp -p "$prefix/$file" "$HOME/$file"
- fi
-done < "$manifest"
+ dirto="$HOME/$dir"
+ docopy=0
+ if [[ ! -d "$dirto" ]]; then
+ echo Making directory $dirto...
+ mkdir -p "$dirto"
+ fi
+ if [[ "$HOME/$file" -nt "$prefix/$file" ]]; then
+ read -p "Overwrite newer file $file? [yN] " yn
+ case $yn in
+ [Yy]* ) docopy=1;;
+ * ) echo "Skipping.";;
+ esac
+ else
+ docopy=1
+ fi
+
+ if [ $docopy -eq 1 ]; then
+ echo Copying to $HOME/$file
+ cp -p "$prefix/$file" "$HOME/$file"
+ fi
+done 3< "$manifest"

0 comments on commit 99c0a7b

Please sign in to comment.