From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQHl2-0008Sk-K8 for qemu-devel@nongnu.org; Wed, 19 Mar 2014 10:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQHkw-0007zs-Lb for qemu-devel@nongnu.org; Wed, 19 Mar 2014 10:46:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQHkw-0007zj-Cf for qemu-devel@nongnu.org; Wed, 19 Mar 2014 10:46:10 -0400 Date: Wed, 19 Mar 2014 10:45:54 -0400 From: Jeff Cody Message-ID: <20140319144554.GB4189@localhost.localdomain> References: <5e57ec8dce227b3095dd476e893137f2b14c0d81.1395105370.git.jcody@redhat.com> <20140319133925.GA3019@irqsave.net> <20140319141948.GA4189@localhost.localdomain> <5329A977.5030801@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5329A977.5030801@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/4] block: qemu-iotests - add common.qemu, for bash-controlled qemu tests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@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.