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

Re: [Xen-devel] [PATCH] xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry.



On Thu, 2014-01-30 at 13:02 +0000, Joby Poriyath wrote:
> On Thu, Jan 30, 2014 at 12:07:34PM +0000, Ian Campbell wrote:
> > On Thu, 2014-01-30 at 12:01 +0000, Joby Poriyath wrote:
> > > > > @@ -394,7 +396,7 @@ class Grub2ConfigFile(_GrubConfigFile):
> > > > >                  continue
> > > > >  
> > > > >              # new image
> > > > > -            title_match = re.match('^menuentry ["\'](.*)["\'] 
> > > > > (.*){', l)
> > > > > +            title_match = re.match('^menuentry ["\'](.*?)["\'] 
> > > > > (.*){', l)
> > > > 
> > > > Why is this necessary? fedora-19 also have the aformentioned "--class
> > > > red, --class gnu" yet is parsed happily.
> > > 
> > > A menuentry from RHEL 7 looks like this...
> > > 
> > > menuentry 'Red Hat Enterprise Linux Everything, with Linux 
> > > 0-rescue-af34f0b8cf364cdbbe6d093f8228a37f' --class red --class gnu-linux 
> > > --class gnu --class os $menuentry_id_option 
> > > 'gnulinux-0-rescue-af34f0b8cf364cdbbe6d093f8228a37f-advanced-d23b8b49-4cfe-4900-8ef1-ec80bc633163'
> > >  
> > > 
> > > So we need 'lazy' match with '.*?'.
> > 
> > ".*" already matches zero or more characters, so I'm not sure what ".*?"
> > means in addition to that, do you have a reference?
> 
> http://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy

Thanks, pure punctuation is a bit tricky to for a search engine...

> > Perhaps ["\']([^"\']*)["\'] is more accurate (i.e. disallow quotes in
> > the name itself, although you might have to split into handling " and '
> > separately to be more correct

Any thoughts on this?

I suppose it depends a bit on the rules for mixing quotes in grub, e.g.
is
        menuentry "Ian's super cool Linux"

allowed.

On the other hand pygrub is very much best effort so as long as it works
with the current set of inputs which we are aware of then .*? is fine.

> > 
> > Have you run this new regex over tools/pygrub/examples?
> 
> I ran this regex over examples. 

Great.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.