* [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
@ 2013-04-16 9:48 Kevin Wolf
2013-04-16 12:26 ` Eric Blake
0 siblings, 1 reply; 7+ messages in thread
From: Kevin Wolf @ 2013-04-16 9:48 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha
$QEMU_PROG happens to be 'qemu' in my setup, so this sed command
replaces a bit too much. Restrict it to the start of the line and to
when it's followed by a colon, i.e. the form used by error messages.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/common.filter | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index bc5f250..a7f889a 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -155,7 +155,7 @@ _filter_qemu_io()
# replace occurrences of QEMU_PROG with "qemu"
_filter_qemu()
{
- sed -e "s#$(basename $QEMU_PROG)#QEMU_PROG#g"
+ sed -e "s#^$(basename $QEMU_PROG):#QEMU_PROG:#g"
}
# make sure this script returns success
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 9:48 [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu Kevin Wolf
@ 2013-04-16 12:26 ` Eric Blake
2013-04-16 13:16 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2013-04-16 12:26 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, stefanha
[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]
On 04/16/2013 03:48 AM, Kevin Wolf wrote:
> $QEMU_PROG happens to be 'qemu' in my setup, so this sed command
> replaces a bit too much. Restrict it to the start of the line and to
> when it's followed by a colon, i.e. the form used by error messages.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> tests/qemu-iotests/common.filter | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index bc5f250..a7f889a 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -155,7 +155,7 @@ _filter_qemu_io()
> # replace occurrences of QEMU_PROG with "qemu"
> _filter_qemu()
> {
> - sed -e "s#$(basename $QEMU_PROG)#QEMU_PROG#g"
> + sed -e "s#^$(basename $QEMU_PROG):#QEMU_PROG:#g"
Why spawn a basename process, when you can use shell to do the same?
Also, the g modifier is worthless once you have a ^ anchor, since sed
can only replace one ^ per line. And you don't need sed's -e option for
a single script.
The following is identical, with less typing:
_filter_qemu()
{
sed "s#^${QEMU_PROG##*/}:#QEMU_PROG#"
}
That said, your more verbose version is still functionally correct, so
you can add:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 12:26 ` Eric Blake
@ 2013-04-16 13:16 ` Stefan Hajnoczi
2013-04-16 13:52 ` Markus Armbruster
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2013-04-16 13:16 UTC (permalink / raw)
To: Eric Blake; +Cc: Kevin Wolf, qemu-devel
On Tue, Apr 16, 2013 at 06:26:38AM -0600, Eric Blake wrote:
> On 04/16/2013 03:48 AM, Kevin Wolf wrote:
> > $QEMU_PROG happens to be 'qemu' in my setup, so this sed command
> > replaces a bit too much. Restrict it to the start of the line and to
> > when it's followed by a colon, i.e. the form used by error messages.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> > tests/qemu-iotests/common.filter | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> > index bc5f250..a7f889a 100644
> > --- a/tests/qemu-iotests/common.filter
> > +++ b/tests/qemu-iotests/common.filter
> > @@ -155,7 +155,7 @@ _filter_qemu_io()
> > # replace occurrences of QEMU_PROG with "qemu"
> > _filter_qemu()
> > {
> > - sed -e "s#$(basename $QEMU_PROG)#QEMU_PROG#g"
> > + sed -e "s#^$(basename $QEMU_PROG):#QEMU_PROG:#g"
>
> Why spawn a basename process, when you can use shell to do the same?
> Also, the g modifier is worthless once you have a ^ anchor, since sed
> can only replace one ^ per line. And you don't need sed's -e option for
> a single script.
sed -e is the convention in qemu-iotests.
Dropping the 'g' would be nice.
The problem with the POSIX shell string replacement is that the syntax
is horrible. I can never remember what ${%}, ${%%}, ${#} and
%{##} do. $(basename $QEMU_PROG) is clear (although it doesn't handle
spaces in the filename!).
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 13:16 ` Stefan Hajnoczi
@ 2013-04-16 13:52 ` Markus Armbruster
2013-04-16 15:08 ` Stefan Hajnoczi
2013-04-16 13:56 ` Kevin Wolf
2013-04-16 14:08 ` Eric Blake
2 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2013-04-16 13:52 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel
Stefan Hajnoczi <stefanha@redhat.com> writes:
[...]
> The problem with the POSIX shell string replacement is that the syntax
> is horrible. I can never remember what ${%}, ${%%}, ${#} and
> %{##} do. $(basename $QEMU_PROG) is clear (although it doesn't handle
> spaces in the filename!).
Here's how I cope. # is left of % my keyboard. # matches "on the
left", % "on the right". #/% are "short" and pick the shortest matching
pattern. ##/%% are "long" and pick the longest matching pattern.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 13:52 ` Markus Armbruster
@ 2013-04-16 15:08 ` Stefan Hajnoczi
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2013-04-16 15:08 UTC (permalink / raw)
To: Markus Armbruster; +Cc: Kevin Wolf, qemu-devel
On Tue, Apr 16, 2013 at 03:52:14PM +0200, Markus Armbruster wrote:
> Stefan Hajnoczi <stefanha@redhat.com> writes:
>
> [...]
> > The problem with the POSIX shell string replacement is that the syntax
> > is horrible. I can never remember what ${%}, ${%%}, ${#} and
> > %{##} do. $(basename $QEMU_PROG) is clear (although it doesn't handle
> > spaces in the filename!).
>
> Here's how I cope. # is left of % my keyboard. # matches "on the
> left", % "on the right". #/% are "short" and pick the shortest matching
> pattern. ##/%% are "long" and pick the longest matching pattern.
Nice :).
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 13:16 ` Stefan Hajnoczi
2013-04-16 13:52 ` Markus Armbruster
@ 2013-04-16 13:56 ` Kevin Wolf
2013-04-16 14:08 ` Eric Blake
2 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2013-04-16 13:56 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
Am 16.04.2013 um 15:16 hat Stefan Hajnoczi geschrieben:
> On Tue, Apr 16, 2013 at 06:26:38AM -0600, Eric Blake wrote:
> > On 04/16/2013 03:48 AM, Kevin Wolf wrote:
> > > $QEMU_PROG happens to be 'qemu' in my setup, so this sed command
> > > replaces a bit too much. Restrict it to the start of the line and to
> > > when it's followed by a colon, i.e. the form used by error messages.
> > >
> > > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > > ---
> > > tests/qemu-iotests/common.filter | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> > > index bc5f250..a7f889a 100644
> > > --- a/tests/qemu-iotests/common.filter
> > > +++ b/tests/qemu-iotests/common.filter
> > > @@ -155,7 +155,7 @@ _filter_qemu_io()
> > > # replace occurrences of QEMU_PROG with "qemu"
> > > _filter_qemu()
> > > {
> > > - sed -e "s#$(basename $QEMU_PROG)#QEMU_PROG#g"
> > > + sed -e "s#^$(basename $QEMU_PROG):#QEMU_PROG:#g"
> >
> > Why spawn a basename process, when you can use shell to do the same?
> > Also, the g modifier is worthless once you have a ^ anchor, since sed
> > can only replace one ^ per line. And you don't need sed's -e option for
> > a single script.
>
> sed -e is the convention in qemu-iotests.
>
> Dropping the 'g' would be nice.
Okay, I just updated the commit to drop the 'g'.
> The problem with the POSIX shell string replacement is that the syntax
> is horrible. I can never remember what ${%}, ${%%}, ${#} and
> %{##} do. $(basename $QEMU_PROG) is clear (although it doesn't handle
> spaces in the filename!).
That's exactly my problem as well.
Kevin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu
2013-04-16 13:16 ` Stefan Hajnoczi
2013-04-16 13:52 ` Markus Armbruster
2013-04-16 13:56 ` Kevin Wolf
@ 2013-04-16 14:08 ` Eric Blake
2 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2013-04-16 14:08 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
On 04/16/2013 07:16 AM, Stefan Hajnoczi wrote:
>>> + sed -e "s#^$(basename $QEMU_PROG):#QEMU_PROG:#g"
>>
>> Why spawn a basename process, when you can use shell to do the same?
> The problem with the POSIX shell string replacement is that the syntax
> is horrible. I can never remember what ${%}, ${%%}, ${#} and
> %{##} do. $(basename $QEMU_PROG) is clear (although it doesn't handle
> spaces in the filename!).
As written, it also doesn't handle a leading '-' in the name. To be
robust, it should be $(basename -- "$QEMU_PROG") - and even then, it
still fails if $QEMU_PROG has a trailing newline (but no one is that
perverse in how they name their program, right?). The shell variant
never goofs on any of those corner cases. But I can totally understand
your aversion to line noise, and as I'm doubtful that anyone will run
the testsuite while trying to stress extreme corner-case $QEMU_PROG
naming conventions, I can certainly live with keeping $(basename
$QEMU_PROG) form for legibility.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-04-16 15:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-16 9:48 [Qemu-devel] [PATCH] qemu-iotests: Fix _filter_qemu Kevin Wolf
2013-04-16 12:26 ` Eric Blake
2013-04-16 13:16 ` Stefan Hajnoczi
2013-04-16 13:52 ` Markus Armbruster
2013-04-16 15:08 ` Stefan Hajnoczi
2013-04-16 13:56 ` Kevin Wolf
2013-04-16 14:08 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).