From 8f5934e86412f2626517d42e0ad87f1c04119098 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 4 Jul 2024 21:53:26 -0700 Subject: [PATCH] move inner loop out of outer loop --- update | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/update b/update index e912450..f805da4 100755 --- a/update +++ b/update @@ -137,31 +137,31 @@ for d in home sh vim; do discover "$d" > _new/hashes.txt || die 'failed to find new files' - different < _new/hashes.txt > _new/updates.txt || + different < _new/hashes.txt >> _new/updates.txt || die 'failed to compare files' - - LC_ALL=C sort < _new/updates.txt > _new/sorted.txt || - die 'failed to sort file paths' - - while read -r f; do - desire "$f" || continue - - if [ -f "_new/$f" ] && ! [ -f "$f" ]; then - warn " + $f" - cp -p "_new/$f" "$f" - elif ! [ -f "_new/$f" ] && [ -f "$f" ]; then - warn " - $f" - elif [ "_new/$f" -nt "$f" ]; then - # NOTE: this does not play well with git --patch. - # don't use this script when you have git! - warn " * $f" - backup "$f" - cp -p "_new/$f" "$f" - elif [ "_new/$f" -ot "$f" ]; then - warn " / $f" - #else warn " = $f" - fi - done < _new/sorted.txt done +LC_ALL=C sort < _new/updates.txt > _new/sorted.txt || +die 'failed to sort file paths' + +while read -r f; do + desire "$f" || continue + + if [ -f "_new/$f" ] && ! [ -f "$f" ]; then + warn " + $f" + cp -p "_new/$f" "$f" + elif ! [ -f "_new/$f" ] && [ -f "$f" ]; then + warn " - $f" + elif [ "_new/$f" -nt "$f" ]; then + # NOTE: this does not play well with git --patch. + # don't use this script when you have git! + warn " * $f" + backup "$f" + cp -p "_new/$f" "$f" + elif [ "_new/$f" -ot "$f" ]; then + warn " / $f" + #else warn " = $f" + fi +done < _new/sorted.txt + clean