import os, posix
createDir("dir1/a")
createDir("dir1/b")
createDir("dir1/c")
let ret1 = chmod("dir1/b", 0o111)
echo "ret1 = ", ret1
try:
removeDir ("dir1")
except:
echo "removeDir(\"dir1\") failed"
$ ./createremove
ret1 = 0
removeDir("dir1") failed
$ ls -l dir1/
total 0
d--x--x--x 1 steve steve 0 Feb 8 21:46 b
drwxr-xr-x 1 steve steve 0 Feb 8 21:46 c
I found this because makepkg leaves the pkg directory like this after a failed build: https://bugs.archlinux.org/task/50439This is considered a feature not a bug, perhaps the same is true of removeDir, but it's perhaps helpful to note this behaviour as it took me a while to understand what was happening. Basically removeDir removes everything until it comes across a dir like that in the tree, then throws an exception and stops deleting stuff leaving a kind of half finished job without any error message to give a clue. If you run it with root permission it will delete a dir like that no problem, and you don't need root permission to chmod the dir to the usual 0o755 either, as you own it, so you can chmod it then removeDir afterwards. I don't really know if removeDir should handle this situation better or differently, rm - r asks if it should delete things like that so you have to write y or n, for example.