dotglob FTW. Doesn't expand . or .. but be explicit just in case.

This commit is contained in:
Aron Griffis
2014-02-19 20:43:18 -05:00
parent 5f96190eb5
commit e783556e6b
+8 -4
View File
@@ -46,10 +46,10 @@ deep-cp() {
# cp doesn't like being called without source params,
# so make sure they expand to something first.
# subshell to avoid surprising caller with nullglob.
# subshell to avoid surprising caller with shopts.
(
shopt -s nullglob
set -- "$source"/!(tmp) "$source"/.{[!.],.?}*
shopt -s nullglob dotglob
set -- "$source"/!(tmp|.|..)
[[ $# == 0 ]] || cp -a "$@" "$target"
)
}
@@ -62,7 +62,11 @@ deep-mv() {
# Does some serious deleting.
deep-rm() {
rm -rf "$1"/!(tmp) "$1"/.{[!.],.?}*
# subshell to avoid surprising caller with shopts.
(
shopt -s dotglob
rm -rf "$1"/!(tmp|.|..)
)
}