grub-devel
[Top][All Lists]
Advanced

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

[PATCH] Make regexp update environment vars with matched sub-strings


From: BVK Chaitanya
Subject: [PATCH] Make regexp update environment vars with matched sub-strings
Date: Wed, 4 Aug 2010 19:49:27 +0530

Hi,


Attached patch adds support for updating environment variables with
sub-strings that matched as per the regular expression groups.  For
this, regexp command now has a new option "-s [NUMBER:]NAME" that can
be repeated multiple number of times.  The NUMBER field is the index
of groups used in the regular expression.  These group indexes are
counted from 1, and zero can be used for complete match.  Also, when
NUMBER: is omitted it defaults to first group.  Some examples are
given below:


regexp -s version /boot/vmlinuz-(.*) /boot/vmlinuz-2.6.26; echo $version

OUTPUTS: 2.6.26


regexp -s 1:basename -s 2:version /boot/(vmlinuz-(.*))
/boot/vmlinuz-2.6.26; echo $basename $version

OUTPUTS: vmlinuz-2.6.26    2.6.26


regexp -s 0:match -s 1:basename -s 2:version  (vmlinuz-(.*))
/boot/vmlinuz-2.6.26; echo $match $basename $version

OUTPUTS: vmlinuz-2.6.26    vmlinuz-2.6.26    2.6.26



regards,
bvk.chaitanya

Attachment: regexp-vars.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]