From 1a8a43ec62fbdc5645cba02aaf14e618f52e7e35 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 14 May 2020 10:18:51 +0300 Subject: [PATCH] kiss: POSIX find usage. Closes #154 --- kiss | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kiss b/kiss index cf29729..dcfcee0 100755 --- a/kiss +++ b/kiss @@ -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