From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmrUz-0000xo-8T for qemu-devel@nongnu.org; Mon, 16 Jan 2012 13:41:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmrUx-0006tQ-Rm for qemu-devel@nongnu.org; Mon, 16 Jan 2012 13:41:41 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:41052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmrUx-0006t4-PF for qemu-devel@nongnu.org; Mon, 16 Jan 2012 13:41:39 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Jan 2012 13:41:37 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 3CA72D400CD for ; Mon, 16 Jan 2012 12:16:48 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0GHGlTO220592 for ; Mon, 16 Jan 2012 12:16:47 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0GHGiho014190 for ; Mon, 16 Jan 2012 15:16:44 -0200 Date: Mon, 16 Jan 2012 11:16:40 -0600 From: Ryan Harper Message-ID: <20120116171640.GB25198@us.ibm.com> References: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> <1326492321-13540-3-git-send-email-ryanh@us.ibm.com> <4F10BB74.4050308@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F10BB74.4050308@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/4] Add cleanup function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Ryan Harper , qemu-devel@nongnu.org * Eric Blake [2012-01-13 17:18]: > On 01/13/2012 03:05 PM, Ryan Harper wrote: > > Create a cleanup function and call it from all exits so we don't leave > > temp files and directories around since we change the name on each invocation. > > > > Also, no need to delete the files in the tmpdir, so just remove the tmpdir > > if it exists. > > > > Signed-off-by: Ryan Harper > > --- > > qemu-test | 11 +++++++++-- > > 1 files changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/qemu-test b/qemu-test > > index cd102a7..71c1ba1 100755 > > --- a/qemu-test > > +++ b/qemu-test > > @@ -1,7 +1,14 @@ > > #!/bin/sh > > > > +cleanup() { > > + if test -n "$tmpdir"; then > > + rm -rf $tmpdir; > > + fi > > +} > > + > > if test -z "$1" -o -z "$2"; then > > echo "Usage: $0 QEMU TEST1 [TEST2 ...]" > > + cleanup > > exit 1 > > Is it worth using 'trap cleanup 0' to install the cleanup handler up > front, instead of modifying all exit call sites? I thought about that, but it seemed to require switching to /bin/bash and I know Anthony had written the scripts carefully to be /bin/sh. > > -- > Eric Blake eblake@redhat.com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx ryanh@us.ibm.com