scripts/functions
changeset 1148 081205fd3790
parent 1138 ae135a73e338
child 1149 df32ef8825f9
     1.1 --- a/scripts/functions	Mon Jan 12 21:35:23 2009 +0000
     1.2 +++ b/scripts/functions	Tue Jan 20 20:10:50 2009 +0000
     1.3 @@ -242,11 +242,18 @@
     1.4      return 0
     1.5  }
     1.6  
     1.7 -# Removes one or more directories, even if it is read-only
     1.8 +# Removes one or more directories, even if it is read-only, or its parent is
     1.9  # Usage: CT_DoForceRmdir dir [...]
    1.10  CT_DoForceRmdir() {
    1.11 -    CT_DoExecLog ALL chmod -R u+w "${@}"
    1.12 -    CT_DoExecLog ALL rm -rf "${@}"
    1.13 +    local dir
    1.14 +    local mode
    1.15 +    for dir in "${@}"; do
    1.16 +        [ -d "${dir}" ] || continue
    1.17 +        mode="$(stat -c '%a' "${dir}")"
    1.18 +        CT_DoExecLog ALL chmod -R u+w "$(dirname "${dir}")"
    1.19 +        CT_DoExecLog ALL rm -rf "${dir}"
    1.20 +        CT_DoExecLog ALL chmod -R ${mode} "$(dirname "${dir}")"
    1.21 +    done
    1.22  }
    1.23  
    1.24  # Echoes the specified string on stdout until the pipe breaks.