kiss: POSIX find usage. Closes #154

This commit is contained in:
Dylan Araps 2020-05-14 10:18:51 +03:00
parent e200e8b358
commit 1a8a43ec62
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

13
kiss
View File

@ -353,10 +353,19 @@ pkg_extract() {
# if any files/directories fail (due to mv's lack of
# directory merge capability), simply do the exercise
# again and copy-merge the remaining files/directories.
#
# We can use '-exec {} +' with any arguments between
# the '{}' and '+' as this is not POSIX. We must also
# use '$0' and '$@' to reference all arguments.
#
# Using only '$@' causes a single file from each
# invocation to be left out of the list. Weird, right?
{
find "$$-$dir/." ! -name . -prune -exec mv -f {} . + ||
find "$$-$dir/." ! -name . -prune -exec cp -fRp {} . +
find "$$-$dir/." ! -name . -prune \
-exec sh -c 'mv -f "$0" "$@" .' {} + ||
find "$$-$dir/." ! -name . -prune \
-exec sh -c 'cp -fRp "$0" "$@" .' {} +
} 2>/dev/null
# Remove the directory now that all files have been