Ok, now I've fixed disconnect.sh ;). I even tested it once too :p.
authorW. Trevor King <wking@drexel.edu>
Wed, 26 Nov 2008 19:34:33 +0000 (14:34 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 26 Nov 2008 19:35:08 +0000 (14:35 -0500)
disconnect.sh

index be436faeb1fcbebecd605a62a679174bcb834fcc..cd821414c903b2f4f906bdf7996fbb90ac5a429a 100755 (executable)
@@ -20,13 +20,13 @@ for file in _*; do
     
     # Replace symlinks with their target
     if [ -h ~/$dotfile ]; then
-       echo -n ""
-       #rm -f ~/$dotfile
-       #mv $file ~/$dotfile
+       echo "De-symlink ~/$dotfile"
+       rm -f ~/$dotfile
+       mv $file ~/$dotfile
     fi
 done
 
-if [ $BASH_RC == "yes" ]; then
+if [ $BASHRC == "yes" ]; then
     # We may have a dotfiles section in ~/.bashrc.  Strip it out.
     BC="### ---- begin .dotfiles section ---- (keep this magic comment)"
     EC="### ---- end .dotfiles section ---- (keep this magic comment)"
@@ -36,12 +36,22 @@ if [ $BASH_RC == "yes" ]; then
     AWKSCRIPT="$AWKSCRIPT if(copy==1 && \$0 != \"$EC\"){print \$0}"
     AWKSCRIPT="$AWKSCRIPT}"
     
+    echo "Strip dotfiles section from ~/.bashrc"
     awk "$AWKSCRIPT" ~/.bashrc > bashrc_stripped
     
     # see if the stripped file is any different
-    DIFF=`diff ~/.bashrc bashrc_stripped` || exit 1
+    DIFF=`diff ~/.bashrc bashrc_stripped`
+    if [ $? -ne 1 ]; then exit 1; fi   # diff failed, bail
     if [ -n "$DIFF" ]; then
+       echo "Replace ~/.bashrc with stripped version"
        rm -f ~/.bashrc
        cp bashrc_stripped ~/.bashrc
+    else
+       echo "No dotfiles section in ~/.bashrc"
     fi
 fi
+
+DOTFILES_DIR=`pwd`
+cd
+echo "Remove the dotfiles dir $DOTFILES_DIR"
+rm -rf $DOTFILES_DIR