diff --git a/.local/bin/renameswap b/.local/bin/renameswap index 2b9e5ed3..2e65b85b 100755 --- a/.local/bin/renameswap +++ b/.local/bin/renameswap @@ -14,7 +14,7 @@ EOF [ "$1" = "--" ] && shift ## We need a temp file is case both files are in the same folder. We use the -## unsecure option since we do not want to create a empty file in +## unsecure option since we do not want to create an empty file in ## advance. Indeed, creating a file with mktemp is problematic for folders since ## non-GNU mv can only move _into_ an existing folder. But we do not overwrite ## if file exists. @@ -30,7 +30,9 @@ case "$2" in esac if ! mv -n "$1" "$TEMPFILE"; then - echo >&2 "Race condition, exiting. Try again." + echo >&2 "Cannot move to temporary file '$TEMPFILE' (maybe try again)" fi -mv -n "$2" "$DIR2/${0##*/}" +## We need to specify the directories because of non-uniform behaviour across +## the various 'mv' implementations. +mv -n "$2" "$DIR2/${1##*/}" mv -n "$TEMPFILE" "$DIR1/${2##*/}"