From eae4405d5b4fb0a07ff8b5034700c729f3961f4d Mon Sep 17 00:00:00 2001 From: ardentsword Date: Tue, 7 Feb 2017 14:03:16 +0100 Subject: [PATCH] The solve-stow now backups all conflicted files --- README.md | 3 +++ remove-stow-conflicts.sh | 26 -------------------------- solve-stow.sh | 10 ++++++++++ 3 files changed, 13 insertions(+), 26 deletions(-) delete mode 100755 remove-stow-conflicts.sh create mode 100755 solve-stow.sh diff --git a/README.md b/README.md index 8ca8c8d..1e81f8e 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,6 @@ To make the files simlinks use `stow ` For example: `stow bash` + +To solve all conflicts: (this will backup all conflicted files to file.back, to delete instead of backup simply uncomment the rm line and comment the mv line) +`./solve-stow.sh ` diff --git a/remove-stow-conflicts.sh b/remove-stow-conflicts.sh deleted file mode 100755 index 575a01a..0000000 --- a/remove-stow-conflicts.sh +++ /dev/null @@ -1,26 +0,0 @@ -#! /bin/sh - -# remove-stow-conflicts -- -# remove all conflicts detected by stow, but that are -# already links to previous stow packages... - -# $Id: remove-stow-conflicts,v 1.1 1997/10/17 21:19:03 cdua Exp cdua $ -# Carlos Duarte, 970903/971017 - -stow -nvc $* 2>&1 \ - | sed -n '/^CONFLICT/s/^.*vs\. //p' \ - | while read i; do - test -L $i || { - echo Skipping $i ... - continue - } - - point_to=`ls -ald $i | awk '{print $NF}'` - - #echo $i points to $point_to - case $point_to in - ..*/stow/* | ..*/?stow/* | stow/* ) - echo "Deleting $i (link to $point_to)"... - rm -f $i - esac -done diff --git a/solve-stow.sh b/solve-stow.sh new file mode 100755 index 0000000..ef08c6b --- /dev/null +++ b/solve-stow.sh @@ -0,0 +1,10 @@ +#! /bin/sh + +stow -nv $1 2>&1 \ + | sed -n 's/ \* existing target is neither a link nor a directory: //p' \ + | while read i; do + echo Backup up ../$i to ../$i.back + mv ../$i ../$i.back + #rm -f ../$i +done +stow $1 \ No newline at end of file