[PATCH 17/18] Place the open() call inside the do{} struct and prevent failing close
- From
Célestin Matte <celestin.matte@ensimag.fr>
- Date
- Jun 6, 2013, 19:34 UTC
- Message-ID
- <1370547263-13558-18-git-send-email-celestin.matte@ensimag.fr>
- In-Reply-To
- <1370547263-13558-1-git-send-email-celestin.matte@ensimag.fr>
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 make it fail systematically Change the error message to state that what fails is a fork(), not a file opening. Use autodie to properly exit when a print or open call fails.
Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr> Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> --- 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-to-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)'; use URI::Escape; use Readonly; +use autodie; # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced Readonly my $SLASH_REPLACEMENT => '%2F'; @@ -363,8 +364,6 @@ sub run_git { local $/ = undef; <$git> }; - close($git); - return $res; }
-- 1.7.9.5