From: Ian Campbell Subject: Re: [PATCH] xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry. Date: Thu, 30 Jan 2014 14:38:57 +0000 Message-ID: <1391092737.5650.7.camel@kazak.uk.xensource.com> References: <20140130113126.GA3326@citrix.com> <52EA3B67.2070707@citrix.com> <20140130120107.GA3441@citrix.com> <1391083654.29487.21.camel@kazak.uk.xensource.com> <20140130130241.GB3441@citrix.com> <1391090818.29487.36.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: M A Young Cc: Andrew Cooper , Joby Poriyath , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2014-01-30 at 14:32 +0000, M A Young wrote: > On Thu, 30 Jan 2014, Ian Campbell wrote: > > > 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 went for ["\']([^"\']*)["\'] in a patch I added to Fedora pygrub in May > last year. That seems to work fine for recent Fedora versions which will > be somewhat similar to RHEL 7. Oops, sorry, did I manage to drop that patch on the ground? Ian.