[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rmdir -p foo/bar/nonexistent

From: Koblinger Egmont
Subject: Re: rmdir -p foo/bar/nonexistent
Date: Tue, 11 Apr 2006 13:08:30 +0200
User-agent: Mutt/1.5.8i


> > as "mkdir -p" succeeds if part of the tree is already created, I'd
> > expect "rmdir -p" to succeed if part of the tree is already removed.
> test ! -e "$dir" || rmdir -p "$dir"

Sorry, I guess I wasn't clear, and now I see how we misunderstood each

When I wrongly used the word "succeed" I didn't mean the exit status, I
meant to proceed with parent directories and try to erase them too. This
time I don't really care about the exit status of rmdir. My expectation is
that if "a/b/c" is an empty directory then "rmdir -p a/b/c/d/e" would remove
the a/b/c directory, then remove a/b if it's empty, then remove a if it's
empty. Currently it fails since a/b/c/d/e doesn't exist and doesn't proceed
with checking a/b/c/d, a/b/c and so on...

I also found a simpler workaround for my needs than a while loop, namely:
  mkdir -p "$dir"
  rmdir -p "$dir"
has the same effect as I'd expect `rmdir -p "$dir"' to work. (Well, only if
the deepest existing directory is writable, no disc full blah blah blah...)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]