From: Paul Eggert Date: Fri, 24 Nov 2017 06:23:03 +0000 (-0800) Subject: gzexe: ensure file always exists X-Git-Tag: v1.9~5 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b06803378a7fe81e8fd9ec0cfb38c8e304a44b32;p=debian%2Fgzip gzexe: ensure file always exists * gzexe.in: When in a filesystem that does not support symlinks, use rm+cp rather than mv to make backups, so that the argument file always exists. --- diff --git a/gzexe.in b/gzexe.in index 721aba4..65b2de2 100644 --- a/gzexe.in +++ b/gzexe.in @@ -213,7 +213,10 @@ EOF printf >&2 '%s\n' "$0: $tmp: cannot chmod" continue } - ln -f "$file" "$file~" 2>/dev/null || mv -f "$file" "$file~" || { + ln -f "$file" "$file~" 2>/dev/null || { + # Hard links may not work. Fall back on rm+cp so that $file always exists. + rm -f "$file~" && cp -p "$file" "$file~" + } || { res=$? printf >&2 '%s\n' "$0: cannot backup $i as $i~" continue