From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joby Poriyath Subject: Re: [PATCH] xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry. Date: Thu, 30 Jan 2014 13:02:41 +0000 Message-ID: <20140130130241.GB3441@citrix.com> References: <20140130113126.GA3326@citrix.com> <52EA3B67.2070707@citrix.com> <20140130120107.GA3441@citrix.com> <1391083654.29487.21.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1391083654.29487.21.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Andrew Cooper , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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 > > 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 > > Have you run this new regex over tools/pygrub/examples? I ran this regex over examples. Thanks, Joby