qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
	kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/4] block: qemu-iotests - add common.qemu, for bash-controlled qemu tests
Date: Wed, 19 Mar 2014 10:45:54 -0400	[thread overview]
Message-ID: <20140319144554.GB4189@localhost.localdomain> (raw)
In-Reply-To: <5329A977.5030801@redhat.com>

On Wed, Mar 19, 2014 at 08:28:07AM -0600, Eric Blake wrote:
> On 03/19/2014 08:19 AM, Jeff Cody wrote:
> 
> >>> +    then
> >>> +        _timed_wait_for ${h} "${@: -1}"
> >>
> >> You have done shift before this. Aren't ${*} the remaining strings to wait for ?
> >>
> > 
> > I could probably get rid of the 2nd shift, although I would have to
> > adjust the conditional below.  
> > 
> > I do ${@: -1} because I want the very last whole string to be the item
> > to wait for - this is only needed to accommodate pathnames with spaces
> > inside the QMP string.
> 
> ${@: -1} is not portable:
> 
> $ bash -c 'set 1 2 3; echo ${@: -1}'
> 3
> $ dash -c 'set 1 2 3; echo ${@: -1}'
> dash: 1: Bad substitution
> 
> If you want the last argument, you'll have to do something hideous like:
> 
> eval \${$#}
> 
> Short of using eval, there is no portable way to get at the last
> positional argument in dash.
> 

Yes, and there are likely other bash-isms in some of the shell
scripts in qemu-iotests.  Since #!/bin/bash is explicitly specified,
it seems reasonable that bash-isms would be allowed.  If it was
#!/bin/sh specified as the interpreter, then I would understand
remaining constrained to POSIX-only.

But I think in your next message you have a nice POSIX compatible
method of doing it with shifts, and it is probably best to default to
POSIX when practical.  I'll go ahead and change it to the 
'shift $(($# - 1))' method.

  parent reply	other threads:[~2014-03-19 14:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18  1:24 [Qemu-devel] [PATCH 0/4] Add common QEMU control functionality to qemu-iotests Jeff Cody
2014-03-18  1:24 ` [Qemu-devel] [PATCH 1/4] block: qemu-iotests - add common.qemu, for bash-controlled qemu tests Jeff Cody
2014-03-19 13:39   ` Benoît Canet
2014-03-19 14:19     ` Jeff Cody
2014-03-19 14:28       ` Eric Blake
2014-03-19 14:32         ` Eric Blake
2014-03-19 14:45         ` Jeff Cody [this message]
2014-03-19 14:53           ` Eric Blake
2014-04-10  2:03   ` Fam Zheng
2014-03-18  1:24 ` [Qemu-devel] [PATCH 2/4] block: qemu-iotests - update 085 to use common.qemu Jeff Cody
2014-03-19 13:44   ` Benoît Canet
2014-03-18  1:24 ` [Qemu-devel] [PATCH 3/4] block: qemu-iotests - fix image cleanup when using spaced pathnames Jeff Cody
2014-03-19 13:46   ` Benoît Canet
2014-03-18  1:24 ` [Qemu-devel] [PATCH 4/4] block: qemu-iotests: make test 019 and 086 work with " Jeff Cody
2014-03-19 13:47   ` Benoît Canet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140319144554.GB4189@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).