diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2009-01-20 20:10:50 (GMT) |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2009-01-20 20:10:50 (GMT) |
commit | 0fc2762de75ab7c6ef91654dd7883cbbeef7dc92 (patch) | |
tree | cbb31f71a4f522575ea099bd61e97b333bdb1d94 | |
parent | 28176fe21ebb3caec630dd9240020884598bdf8c (diff) |
Forced-removing of a non-existing directory breaks the build.
Noticed by "Andy Johnson" <ajohnson@aecno.com>, who provided a patch that I adapted.
/trunk/scripts/functions | 13 10 3 0 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
-rw-r--r-- | scripts/functions | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/functions b/scripts/functions index 5bf6b3d..b8d31a0 100644 --- a/scripts/functions +++ b/scripts/functions @@ -242,11 +242,18 @@ CT_MktempDir() { return 0 } -# Removes one or more directories, even if it is read-only +# Removes one or more directories, even if it is read-only, or its parent is # Usage: CT_DoForceRmdir dir [...] CT_DoForceRmdir() { - CT_DoExecLog ALL chmod -R u+w "${@}" - CT_DoExecLog ALL rm -rf "${@}" + local dir + local mode + for dir in "${@}"; do + [ -d "${dir}" ] || continue + mode="$(stat -c '%a' "${dir}")" + CT_DoExecLog ALL chmod -R u+w "$(dirname "${dir}")" + CT_DoExecLog ALL rm -rf "${dir}" + CT_DoExecLog ALL chmod -R ${mode} "$(dirname "${dir}")" + done } # Echoes the specified string on stdout until the pipe breaks. |