diff -r ae135a73e338 -r 081205fd3790 scripts/functions --- a/scripts/functions Mon Jan 12 21:35:23 2009 +0000 +++ b/scripts/functions Tue Jan 20 20:10:50 2009 +0000 @@ -242,11 +242,18 @@ 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.