aboutsummaryrefslogtreecommitdiff
path: root/m/copy-if-changed.sh
diff options
context:
space:
mode:
Diffstat (limited to 'm/copy-if-changed.sh')
-rwxr-xr-x[-rw-r--r--]m/copy-if-changed.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/m/copy-if-changed.sh b/m/copy-if-changed.sh
index a8403d0..d46490f 100644..100755
--- a/m/copy-if-changed.sh
+++ b/m/copy-if-changed.sh
@@ -19,7 +19,7 @@ if test -f $src; then
# Both $src and $dst must be files.
- test -f $dst || exit 3
+ test -f $dst || ! test -e $dst || exit 3
# Copy file if it differs
srcfile=$src
@@ -49,7 +49,10 @@ if test -d $src; then
test -e $dst || mkdir -p $dst
test -d $dst || exit 3
-
+
+ # find inode number to identify the src directory later on
+ srcinode=$(ls -id $src | awk '{print $1}')
+
# Create all directories
for dir in $(cd $src && find . -type d); do
dstdir=$dst/$dir
@@ -62,7 +65,7 @@ if test -d $src; then
done
# Delete directories which do not exist
- for dir in $(cd $dst && find . -name 'CVS' -prune -name '.svn' -prune -name '.git' -prune -name '.hg' -prune -name '_darcs' -prune -type d -print); do
+ for dir in $(cd $dst && find . \( -name 'CVS' -o -name '.svn' -o -name '.git' -o -name '.hg' -o -name '_darcs' -o -inum $srcinode \) -prune -o -type d -print); do
srcdir=$src/$dir
dstdir=$dst/$dir
if test -d $srcdir; then
@@ -86,7 +89,7 @@ if test -d $src; then
done
# Delete files which do not exist
- for file in $(cd $dst && find . -name 'CVS' -prune -name '.svn' -prune -name '.git' -prune -name '.hg' -prune -name '_darcs' -prune -type f -print); do
+ for file in $(cd $dst && find . \( -name 'CVS' -o -name '.svn' -o -name '.git' -o -name '.hg' -o -name '_darcs' -o -inum $srcinode \) -prune -o -type f -print); do
srcfile=$src/$file
dstfile=$dst/$file
if test -e $srcfile; then