From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?C=C3=A9lestin=20Matte?= Subject: [PATCH 17/18] Place the open() call inside the do{} struct and prevent failing close Date: Thu, 6 Jun 2013 21:34:22 +0200 Message-ID: <1370547263-13558-18-git-send-email-celestin.matte@ensimag.fr> References: <1370547263-13558-1-git-send-email-celestin.matte@ensimag.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: benoit.person@ensimag.fr, matthieu.moy@grenoble-inp.fr, =?UTF-8?q?C=C3=A9lestin=20Matte?= To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Thu Jun 06 21:35:39 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ukfy8-0001Cd-Ci for gcvg-git-2@plane.gmane.org; Thu, 06 Jun 2013 21:35:32 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753701Ab3FFTfQ convert rfc822-to-quoted-printable (ORCPT ); Thu, 6 Jun 2013 15:35:16 -0400 Received: from mx1.imag.fr ([129.88.30.5]:44291 "EHLO shiva.imag.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753663Ab3FFTfM (ORCPT ); Thu, 6 Jun 2013 15:35:12 -0400 Received: from ensimag.imag.fr (ensimag.imag.fr [195.221.228.12]) by shiva.imag.fr (8.13.8/8.13.8) with ESMTP id r56JZ24X005356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Jun 2013 21:35:02 +0200 Received: from ensibm.imag.fr (ensibm.imag.fr [195.221.228.8]) by ensimag.imag.fr (8.13.8/8.13.8/ImagV2.1.r_ens) with ESMTP id r56JZ4kt021452; Thu, 6 Jun 2013 21:35:04 +0200 Received: from tohwi-K50IE.imag.fr (ensibm [195.221.228.8]) by ensibm.imag.fr (8.13.8/8.13.8/ImagV2.1.sb_ens.pm) with ESMTP id r56JYTp6023108; Thu, 6 Jun 2013 21:35:04 +0200 X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1370547263-13558-1-git-send-email-celestin.matte@ensimag.fr> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (shiva.imag.fr [129.88.30.5]); Thu, 06 Jun 2013 21:35:02 +0200 (CEST) X-IMAG-MailScanner-Information: Please contact MI2S MIM for more information X-MailScanner-ID: r56JZ24X005356 X-IMAG-MailScanner: Found to be clean X-IMAG-MailScanner-SpamCheck: X-IMAG-MailScanner-From: celestin.matte@ensimag.fr MailScanner-NULL-Check: 1371152105.34781@IcLjBkGF5gNI1hqNiyQSvw Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Placing the open() call inside the do{} struct will automatically close= the filehandle if possible. Placing the close() call outside the do{} struct is useless and will ma= ke it fail systematically Change the error message to state that what fails is a fork(), not a fi= le opening. Use autodie to properly exit when a print or open call fails. Signed-off-by: C=C3=A9lestin Matte Signed-off-by: Matthieu Moy --- contrib/mw-to-git/git-remote-mediawiki.perl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-t= o-git/git-remote-mediawiki.perl index 952ddcc..20ddccb 100755 --- a/contrib/mw-to-git/git-remote-mediawiki.perl +++ b/contrib/mw-to-git/git-remote-mediawiki.perl @@ -23,6 +23,7 @@ binmode STDOUT, ':encoding(UTF-8)'; =20 use URI::Escape; use Readonly; +use autodie; =20 # Mediawiki filenames can contain forward slashes. This variable decid= es by which pattern they should be replaced Readonly my $SLASH_REPLACEMENT =3D> '%2F'; @@ -363,8 +364,6 @@ sub run_git { local $/ =3D undef; <$git> }; - close($git); - return $res; } =20 --=20 1.7.9.5