From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqMx-0003Nt-MT for qemu-devel@nongnu.org; Fri, 13 Jan 2012 18:17:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlqMw-00012T-Hg for qemu-devel@nongnu.org; Fri, 13 Jan 2012 18:17:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlqMw-000128-0t for qemu-devel@nongnu.org; Fri, 13 Jan 2012 18:17:10 -0500 Message-ID: <4F10BB74.4050308@redhat.com> Date: Fri, 13 Jan 2012 16:17:08 -0700 From: Eric Blake MIME-Version: 1.0 References: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> <1326492321-13540-3-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1326492321-13540-3-git-send-email-ryanh@us.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigE0F63F0A46482B13C6CD7B2D" Subject: Re: [Qemu-devel] [PATCH 2/4] Add cleanup function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ryan Harper Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE0F63F0A46482B13C6CD7B2D Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 invo= cation. >=20 > Also, no need to delete the files in the tmpdir, so just remove the tm= pdir > if it exists. >=20 > Signed-off-by: Ryan Harper > --- > qemu-test | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/qemu-test b/qemu-test > index cd102a7..71c1ba1 100755 > --- a/qemu-test > +++ b/qemu-test > @@ -1,7 +1,14 @@ > #!/bin/sh > =20 > +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? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigE0F63F0A46482B13C6CD7B2D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPELt0AAoJEKeha0olJ0NqelQH/iswyVH4YWdm55hccipVR1uN /uT/agWMPO9SYFB+QGelvDO7UL+drxc65ij66trlBmaoWgp9E8V09Y6QG7315RkK B02IalVf/fRnQO3Rpn2+Ln/6hnERtIyFplee0Yapig0NL7TrS00Sqgb9KqZtwAuo IHBHnLCn5nE9owRPY68NUQE0/7LGsgNhvFCiHKomhJtM7Soex4e2k/U8yovvv9bL lVKZUiGE4oTIgxfmHfLj/oc1xvaClGjE8ISfxe7+6ILE9nmQQjGQJhoH69Cg0Plh qks3AQ0frFxkDcKag9q76R/WAJHsnw3kj6FTGUlPNIyCxnUFrRCaqxODBCYyEx8= =XRmf -----END PGP SIGNATURE----- --------------enigE0F63F0A46482B13C6CD7B2D--