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

Re: Checking if directory is empty in postrm



On Thu, Nov 19, 1998 at 01:47:33AM +0000, Julian Gilbey wrote:
> > However, a new question arises. Will this work in all cases:
> > 
> > rmdir $LDIR 2>/dev/null && grep -v $LDIR $LDSOCONF >$tmpfile && mv $tmpfile $LDSOCONF || true
> > rm $tempfile   # just in case the mv failed, or grep failed partly
> > 
> > Or is there any trap door I miss?
> 
> What if you have a directory LDIR=/etc/foo/bar but there is another
> directory called /etc/foo/barbar in $LDSOCONF?  Maybe you should
> change the grep command to:
> 
> grep -v "^$LDIR\$" $LDSOCONF
> 
> so that you match the entire line.

This is a good idea, thanks Julian!

(Although, in this special case, it is unlikely, because I speak about
libc5-compat directories. However, it is always good to stay on the safe
side).

Marcus

-- 
"Rhubarb is no Egyptian god."        Debian GNU/Linux        finger brinkmd@ 
Marcus Brinkmann                   http://www.debian.org    master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09


Reply to: