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

Re: [Guillem Jover] Parsing of dpkg status file considered harmful



On Thu, May 31, 2007 at 10:11:39PM +0100, Julian Gilbey wrote:
> On Thu, May 31, 2007 at 10:09:24PM +0200, Florent Rougon wrote:
> > Hi,
> > 
> > Frank Küster <frank@debian.org> wrote:
> > 
> > > Is there any particular reason why did you use the while loop?
> > 
> > Yes.
> > 
> > > Looking at the old code, I would have intuitively used
> > >
> > > md5sum=$(dpkg-query -W -f='${Conffiles}' $package | grep "$file[[:space:]]" | cut -f 3 -d ' ')
> > 
> > This has the problem that $file is interpreted as a regexp; it isn't an
> > exact match (for example, the . preceding file extensions would match
> > any character). I replaced that with a [ $foo = $bla ] test precisely to
> > avoid this problem.
> 
> OK, then, replace grep with perl -ne "/\\Q$file\\E\\s/ && print" or
> something like that.
> 
>    Julian

Or simpler still, something like: fgrep $(echo -e "$file \n$file\t")
(I haven't checked the quoting, sorry.)

   Julian



Reply to: