From 08e10e322a4047836dd79b494e45b8c8eef98339 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jul 2020 22:37:07 -0400 Subject: [PATCH] test --- bin/utils | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/utils b/bin/utils index 301c4e5..7565dfc 100755 --- a/bin/utils +++ b/bin/utils @@ -39,11 +39,19 @@ function un-set-env (){ } # Does some serious copying. -function deep-cp (){ - find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec cp -a '{}' $2 \; - cp -r $1 $2 - # echo copying $1 to $2 -} +deep-cp() { + declare source="$1" target="$2" + + mkdir -p "$target" + + # cp doesn't like being called without source params, + # so make sure they expand to something first. + # subshell to avoid surprising caller with shopts. + ( + shopt -s nullglob dotglob + set -- "$source"/!(tmp|.|..) + [[ $# == 0 ]] || cp -a "$@" "$target" + ) # Does some serious moving. function deep-mv (){