diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-23 22:23:03 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-23 23:12:30 -0800 |
commit | b06803378a7fe81e8fd9ec0cfb38c8e304a44b32 (patch) | |
tree | 0e2e6c6ff19f7e94305217d34d8ecb4237114c0d /gzexe.in | |
parent | 10d7ae8ee402d796e484b77f7da3a2c18228e298 (diff) | |
download | gzip-b06803378a7fe81e8fd9ec0cfb38c8e304a44b32.tar.gz |
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.
Diffstat (limited to 'gzexe.in')
-rw-r--r-- | gzexe.in | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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 |