diff options
Diffstat (limited to 'scripts')
-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. |