On Sun, Jun 21, 2009 at 08:20:19AM -0400, Paul Hoffman wrote: > On Sun, Jun 21, 2009 at 10:31:56AM +0100, Chris G wrote: > > It's one of my major gripes with maildir, there appears to be no way > > to safely (as in maildirsafely) remove a maildir folder. > > I would move (rename) the root of the maildir; then you can delete cur, > new, and tmp in any order you like. Not absolutely foolproof, since you > might successfully delete (for example) $maildir/new but not > $maildir/cur, but at least the initial mv should be atomic. > > ----------------------------- cut here ----------------------------- > #!/bin/bash > # Also works in zsh (I think) > if [ $# != 1 ]; then > echo "usage: rmmaildir DIR" >&2 > exit 1 > fi > maildir=$1 > # This should use ${maildir#/} or whatever but I forget the syntax > parent=${maildir%/*} > base=${maildir##*/} > tmp=$parent/.$base.deleting.$$ > if mv $maildir $tmp; then > if rmdir $tmp/new $tmp/cur $tmp/tmp $tmp; then > exit 0 > elif ! mkdir -p $tmp/new $tmp/cur $tmp/tmp; then > echo "Partially deleted" >&2 > exit -1 > fi > else > echo "Can't delete" >&2 > exit 2 > fi > ----------------------------- cut here -----------------------------
Thanks for the tip, but I don't like this way, and I haven't bash installed :) -- Hi, Wu, Yue