aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-05-03 17:32:09 -0300
committerEuAndreh <eu@euandre.org>2023-05-03 17:32:09 -0300
commit6a2e9fb7f37d2bc9f978d3a758fd0c8e33f05614 (patch)
tree140924170a5e804449b080accb1cff11c459f621
parentbin/ifnew: Create tmpfile in the same directory to leverage "mv" in the same ... (diff)
downloaddotfiles-6a2e9fb7f37d2bc9f978d3a758fd0c8e33f05614.tar.gz
dotfiles-6a2e9fb7f37d2bc9f978d3a758fd0c8e33f05614.tar.xz
bin/ifnew: Also add "-v" to "mv" and "rm" when -v is given
-rwxr-xr-xbin/ifnew5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/ifnew b/bin/ifnew
index 402c3b3..161a2ea 100755
--- a/bin/ifnew
+++ b/bin/ifnew
@@ -96,12 +96,15 @@ trap 'rm -f "$STDIN"' EXIT
cat - > "$STDIN"
if ! cmp -s "$STDIN" "$FILE"; then
+ MV_ARGS=''
if [ "$VERBOSE" = true ]; then
printf 'ifnew: "%s" will be updated.\n' "$FILE" >&2
+ MV_ARGS='-v'
fi
- mv "$STDIN" "$FILE"
+ mv $MV_ARGS "$STDIN" "$FILE"
else
if [ "$VERBOSE" = true ]; then
printf 'ifnew: "%s" left unchanged.\n' "$FILE" >&2
+ rm -vf "$STDIN"
fi
fi