Re: Checking if directory is empty in postrm
On Mon, Nov 16, 1998 at 12:28:17AM -0600, john@dhh.gt.org wrote:
> > [ "`ls -1A $dir`" ]
> >
> > This returns '1' if the directory is empty and '0' otherwise. It is
> > not tricked by spaces or other unusual characters in file names.
It's not perfect, however:
mkdir emptydir3; cd emptydir3; touch ./-z
Frankly, I think the only reasonable action to consider in a postrm would
be removing the empty directory, in which case just use rmdir on it
[if this is the only command in the postrm, don't bother with set -e,
if it's one of many steps and can only happen after the set -e follow
rmdir with ||true].
--
Raul
Reply to: