gzexe: work even without the ability to make a hard link
authorJim Meyering <meyering@fb.com>
Wed, 15 Nov 2017 03:34:46 +0000 (19:34 -0800)
committerJim Meyering <meyering@fb.com>
Thu, 16 Nov 2017 14:58:10 +0000 (06:58 -0800)
* gzexe.in: When ln -f fails to create a "~"-style backup,
fall back to using mv -f.
Reported by Bruno Haible in http://debbugs.gnu.org/29266

gzexe.in

index 290fa1cba4264f66bb6d890610ca9c7f95528884..721aba402f5a3e843300144894c16058c82f33ad 100644 (file)
--- a/gzexe.in
+++ b/gzexe.in
@@ -213,7 +213,7 @@ EOF
     printf >&2 '%s\n' "$0: $tmp: cannot chmod"
     continue
   }
-  ln -f "$file" "$file~" || {
+  ln -f "$file" "$file~" 2>/dev/null || mv -f "$file" "$file~" || {
     res=$?
     printf >&2 '%s\n' "$0: cannot backup $i as $i~"
     continue