wok view cookutils/stuff/avoid-hard-link-exist-error.patch @ rev 25503

f3: include extra programs
author Hans-G?nter Theisgen
date Fri Jan 27 10:37:43 2023 +0100 (16 months ago)
parents
children
line source
1 A void error "cp: cannot create hard link 'file1' to 'file2': file exists"
3 --- a/cook
4 +++ b/cook
5 @@ -423,11 +423,9 @@
6 # A bit smarter function than the classic `cp` command
8 copy() {
9 - if [ "$(stat -c %h -- "$1")" -gt 1 ]; then
10 - cp -al "$1" "$2" # copy hardlinks
11 - else
12 - cp -a "$1" "$2" # copy generic files
13 - fi
14 + [ "$(stat -c %h -- "$1")" -gt 1 ] &&
15 + cp -al "$1" "$2" 2>/dev/null || # copy hardlinks
16 + cp -a "$1" "$2" # copy generic files
17 }