wok diff cookutils/stuff/avoid-hard-link-exist-error.patch @ rev 25063

nfs-utils: update web_site
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jun 07 20:10:22 2022 +0000 (2022-06-07)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cookutils/stuff/avoid-hard-link-exist-error.patch	Tue Jun 07 20:10:22 2022 +0000
     1.3 @@ -0,0 +1,19 @@
     1.4 +A void error "cp: cannot create hard link 'file1' to 'file2': file exists"
     1.5 +
     1.6 +--- a/cook
     1.7 ++++ b/cook
     1.8 +@@ -423,11 +423,9 @@
     1.9 + # A bit smarter function than the classic `cp` command
    1.10 + 
    1.11 + copy() {
    1.12 +-	if [ "$(stat -c %h -- "$1")" -gt 1 ]; then
    1.13 +-		cp -al "$1" "$2"	# copy hardlinks
    1.14 +-	else
    1.15 +-		cp -a  "$1" "$2"	# copy generic files
    1.16 +-	fi
    1.17 ++	[ "$(stat -c %h -- "$1")" -gt 1 ] &&
    1.18 ++	cp -al "$1" "$2" 2>/dev/null ||	# copy hardlinks
    1.19 ++	cp -a  "$1" "$2"		# copy generic files
    1.20 + }
    1.21 + 
    1.22 +