]> err.no Git - dotfiles/commitdiff
first shot at shell function variant
authortfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Wed, 16 Oct 2002 00:19:08 +0000 (00:19 +0000)
committertfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Wed, 16 Oct 2002 00:19:08 +0000 (00:19 +0000)
git-svn-id: file:///svn/tfheen/trunk/dotfiles@70 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf

link-dotfiles

index 9206bd909388ed7d7ce9a7252ebd2d4d8bfd90cc..272ef3a12c78e26a449befd94b5ed6234052405e 100755 (executable)
@@ -18,30 +18,36 @@ if test -z "$MD5SUM"; then
     exit 1
 fi
 
-for file in $DOTFILESDIR/*; do
-    file=`basename $file`
-    if ! test -f "$DOTFILESDIR/$file"; then
-        continue
-    fi
-    if test -f $HOME/.$file; then
-        C_MD5SUM=`$MD5SUM < $HOME/.$file | awk '{print $1}'`
-        N_MD5SUM=`$MD5SUM < $DOTFILESDIR/$file | awk '{print $1}'`
-        if test "$C_MD5SUM" = "$N_MD5SUM"; then
-            rm -f $HOME/.$file
-        else
-            found=0
-            for md5 in $KNOWNMD5SUMS; do
-                if [ "$md5" = "$C_MD5SUM" ]; then
-                    rm -f $HOME/.$file
-                    found=1
-                    break
+linkdir () {
+    for file in $1/*; do
+        file=`basename $file`
+        if test -d  "$1/$file"; then
+            :
+        elif ! test -f "$1/$file"; then
+            continue
+        fi
+        if test -f $2/.$file; then
+            C_MD5SUM=`$MD5SUM < $2/.$file | awk '{print $1}'`
+            N_MD5SUM=`$MD5SUM < $1/$file | awk '{print $1}'`
+            if test "$C_MD5SUM" = "$N_MD5SUM"; then
+                rm -f $2/.$file
+            else
+                found=0
+                for md5 in $KNOWNMD5SUMS; do
+                    if [ "$md5" = "$C_MD5SUM" ]; then
+                        rm -f $2/.$file
+                        found=1
+                        break
+                    fi
+                done
+                if [ "$found" = "0" ]; then
+                    echo "$2/.$file different from $1/$file, not known ok, and not symlink: skipping"
+                    continue
                 fi
-            done
-            if [ "$found" = "0" ]; then
-                echo "$HOME/.$file different from $DOTFILESDIR/$file, not known ok, and not symlink: skipping"
-                continue
             fi
         fi
-    fi
-    ln -s $DOTFILESDIR/$file $HOME/.$file
-done
\ No newline at end of file
+        ln -s $1/$file $2/.$file
+    done
+}
+
+linkdir $DOTFILESDIR $HOME