Date: Fri, 24 May 2013 12:24:11 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-hackers@freebsd.org, Kurt Lidl <lidl@pix.net> Subject: Re: find -delete broken, or just used improperly? Message-ID: <20130524102411.GA3984@stack.nl> In-Reply-To: <201305211106.39313.jhb@freebsd.org> References: <20130520192316.GA32531@pix.net> <20130520214731.GA43407@stack.nl> <201305211106.39313.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 21, 2013 at 11:06:39AM -0400, John Baldwin wrote: > On Monday, May 20, 2013 5:47:31 pm Jilles Tjoelker wrote: > > The below patch allows deleting the pathname given to find itself: > > Index: usr.bin/find/function.c > > =================================================================== > > --- usr.bin/find/function.c (revision 250661) > > +++ usr.bin/find/function.c (working copy) > > @@ -442,7 +442,8 @@ > > errx(1, "-delete: forbidden when symlinks are followed"); > > > > /* Potentially unsafe - do not accept relative paths whatsoever */ > > - if (strchr(entry->fts_accpath, '/') != NULL) > > + if (entry->fts_level > FTS_ROOTLEVEL && > > + strchr(entry->fts_accpath, '/') != NULL) > > errx(1, "-delete: %s: relative path potentially not safe", > > entry->fts_accpath); > I'm curious, how would you instruct a patched find to avoid deleteing > the /tmp/foo directory (e.g. if you wanted this to be a job that > pruned empty dirs from /tmp/foo but never pruned the directory > itself). Would -mindepth 1 do it? (Just asking. I have also found > this message annoying but most of the jobs I have seen it on probably > don't want to delete the root path, just descendants.) -mindepth 1 works, as does cd /tmp/foo && find . -... (-delete silently ignores . and ..). -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130524102411.GA3984>