{"thread":{"id":"23493","subject":"[PATCH] git-cvsserver.perl: encourage use of English module and qx() operator","startedAt":"2010-04-16T16:32:45Z","lastAt":"2010-04-16T17:24:27Z","messageCount":5,"participants":["jari.aalto@cante.net","Randal L. Schwartz","Jari Aalto"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"139673","messageId":"1271435565-32370-1-git-send-email-jari.aalto@cante.net","threadId":"23493","inReplyTo":null,"subject":"[PATCH] git-cvsserver.perl: encourage use of English module and qx() operator","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-16T16:32:45Z","receivedAt":"2010-04-16T16:32:45Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\nSubstitute magic variables $<puctuation> with the English.pm\nequivalents for readability. Likewise substitute backtics with the\nalternative qx() for system calls.\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-cvsserver.perl |  151 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 76 insertions(+), 75 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 13751db..0efe8bc 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -19,6 +19,7 @@ use strict;\n use warnings;\n use bytes;\n \n+use English qw( -no_match_vars );\n use Fcntl;\n use File::Temp qw/tempdir tempfile/;\n use File::Path qw/rmtree/;\n@@ -46,7 +47,7 @@ my $DATE_LIST = {\n };\n \n # Enable autoflush for STDOUT (otherwise the whole thing falls apart)\n-$| = 1;\n+$OUTPUT_AUTOFLUSH = 1;\n \n #### Definition and mappings of functions ####\n \n@@ -214,8 +215,8 @@ while (<STDIN>)\n         # we're fairly screwed because we don't know if the client is expecting\n         # a response. If it is, the client will hang, we'll hang, and the whole\n         # thing will be custard.\n-        $log->fatal(\"Don't understand command $_\\n\");\n-        die(\"Unknown command $_\");\n+        $log->fatal(\"Don't understand command $ARG\\n\");\n+        die(\"Unknown command $ARG\");\n     }\n }\n \n@@ -305,8 +306,8 @@ sub req_Root\n        return 0;\n     }\n \n-    my @gitvars = `git config -l`;\n-    if ($?) {\n+    my @gitvars = qx( git config -l );\n+    if ($CHILD_ERROR) {\n        print \"E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\\n\";\n         print \"E \\n\";\n         print \"error 1 - problem executing git-config\\n\";\n@@ -538,19 +539,19 @@ sub req_add\n \n         unless ( defined ( $state->{entries}{$filename}{modified_filename} ) )\n         {\n-            print \"E cvs add: nothing known about `$filename'\\n\";\n+            print \"E cvs add: nothing known about '$filename'\\n\";\n             next;\n         }\n         # TODO : check we're not squashing an already existing file\n         if ( defined ( $state->{entries}{$filename}{revision} ) )\n         {\n-            print \"E cvs add: `$filename' has already been entered\\n\";\n+            print \"E cvs add: '$filename' has already been entered\\n\";\n             next;\n         }\n \n         my ( $filepart, $dirpart ) = filenamesplit($filename, 1);\n \n-        print \"E cvs add: scheduling file `$filename' for addition\\n\";\n+        print \"E cvs add: scheduling file '$filename' for addition\\n\";\n \n         print \"Checked-in $dirpart\\n\";\n         print \"$filename\\n\";\n@@ -579,11 +580,11 @@ sub req_add\n \n     if ( $addcount == 1 )\n     {\n-        print \"E cvs add: use `cvs commit' to add this file permanently\\n\";\n+        print \"E cvs add: use 'cvs commit' to add this file permanently\\n\";\n     }\n     elsif ( $addcount > 1 )\n     {\n-        print \"E cvs add: use `cvs commit' to add these files permanently\\n\";\n+        print \"E cvs add: use 'cvs commit' to add these files permanently\\n\";\n     }\n \n     print \"ok\\n\";\n@@ -620,7 +621,7 @@ sub req_remove\n \n         if ( defined ( $state->{entries}{$filename}{unchanged} ) or defined ( $state->{entries}{$filename}{modified_filename} ) )\n         {\n-            print \"E cvs remove: file `$filename' still in working directory\\n\";\n+            print \"E cvs remove: file '$filename' still in working directory\\n\";\n             next;\n         }\n \n@@ -629,27 +630,27 @@ sub req_remove\n \n         unless ( defined ( $wrev ) )\n         {\n-            print \"E cvs remove: nothing known about `$filename'\\n\";\n+            print \"E cvs remove: nothing known about '$filename'\\n\";\n             next;\n         }\n \n         if ( defined($wrev) and $wrev < 0 )\n         {\n-            print \"E cvs remove: file `$filename' already scheduled for removal\\n\";\n+            print \"E cvs remove: file '$filename' already scheduled for removal\\n\";\n             next;\n         }\n \n         unless ( $wrev == $meta->{revision} )\n         {\n             # TODO : not sure if the format of this message is quite correct.\n-            print \"E cvs remove: Up to date check failed for `$filename'\\n\";\n+            print \"E cvs remove: Up to date check failed for '$filename'\\n\";\n             next;\n         }\n \n \n         my ( $filepart, $dirpart ) = filenamesplit($filename, 1);\n \n-        print \"E cvs remove: scheduling `$filename' for removal\\n\";\n+        print \"E cvs remove: scheduling '$filename' for removal\\n\";\n \n         print \"Checked-in $dirpart\\n\";\n         print \"$filename\\n\";\n@@ -661,11 +662,11 @@ sub req_remove\n \n     if ( $rmcount == 1 )\n     {\n-        print \"E cvs remove: use `cvs commit' to remove this file permanently\\n\";\n+        print \"E cvs remove: use 'cvs commit' to remove this file permanently\\n\";\n     }\n     elsif ( $rmcount > 1 )\n     {\n-        print \"E cvs remove: use `cvs commit' to remove these files permanently\\n\";\n+        print \"E cvs remove: use 'cvs commit' to remove these files permanently\\n\";\n     }\n \n     print \"ok\\n\";\n@@ -709,7 +710,7 @@ sub req_Modified\n     }\n \n     close $fh\n-        or (print \"E failed to write temporary, $filename: $!\\n\"), return;\n+        or (print \"E failed to write temporary, $filename: $ERRNO\\n\"), return;\n \n     # Ensure we have something sensible for the file mode\n     if ( $mode =~ /u=(\\w+)/ )\n@@ -722,7 +723,7 @@ sub req_Modified\n     # Save the file data in $state\n     $state->{entries}{$state->{directory}.$data}{modified_filename} = $filename;\n     $state->{entries}{$state->{directory}.$data}{modified_mode} = $mode;\n-    $state->{entries}{$state->{directory}.$data}{modified_hash} = `git hash-object $filename`;\n+    $state->{entries}{$state->{directory}.$data}{modified_hash} = qx( git hash-object $filename );\n     $state->{entries}{$state->{directory}.$data}{modified_hash} =~ s/\\s.*$//s;\n \n     #$log->debug(\"req_Modified : file=$data mode=$mode size=$size\");\n@@ -824,7 +825,7 @@ sub req_co\n \n     # Provide list of modules, if -c was used.\n     if (exists $state->{opt}{c}) {\n-        my $showref = `git show-ref --heads`;\n+        my $showref = qx( git show-ref --heads );\n         for my $line (split '\\n', $showref) {\n             if ( $line =~ m% refs/heads/(.*)$% ) {\n                 print \"M $1\\t$1\\n\";\n@@ -980,11 +981,11 @@ sub req_update\n     # projects (heads in this case) to checkout.\n     #\n     if ($state->{module} eq '') {\n-        my $showref = `git show-ref --heads`;\n+        my $showref = qx( git show-ref --heads );\n         print \"E cvs update: Updating .\\n\";\n         for my $line (split '\\n', $showref) {\n             if ( $line =~ m% refs/heads/(.*)$% ) {\n-                print \"E cvs update: New directory `$1'\\n\";\n+                print \"E cvs update: New directory '$1'\\n\";\n             }\n         }\n         print \"ok\\n\";\n@@ -1101,7 +1102,7 @@ sub req_update\n \n             $log->info(\"Removing '$filename' from working copy (no longer in the repo)\");\n \n-            print \"E cvs update: `$filename' is no longer in the repository\\n\";\n+            print \"E cvs update: '$filename' is no longer in the repository\\n\";\n             # Don't want to actually _DO_ the update if -n specified\n             unless ( $state->{globaloptions}{-n} ) {\n \t\tprint \"Removed $dirpart\\n\";\n@@ -1249,7 +1250,7 @@ sub req_update\n                 # transmit file, format is single integer on a line by itself (file\n                 # size) followed by the file contents\n                 # TODO : we should copy files in blocks\n-                my $data = `cat $mergedFile`;\n+                my $data = qx( cat $mergedFile );\n                 $log->debug(\"File size : \" . length($data));\n                 print length($data) . \"\\n\";\n                 print $data;\n@@ -1291,7 +1292,7 @@ sub req_ci\n     $updater->update();\n \n     # Remember where the head was at the beginning.\n-    my $parenthash = `git show-ref -s refs/heads/$state->{module}`;\n+    my $parenthash = qx( git show-ref -s refs/heads/$state->{module} );\n     chomp $parenthash;\n     if ($parenthash !~ /^[0-9a-f]{40}$/) {\n \t    print \"error 1 pserver cannot find the current HEAD of module\";\n@@ -1303,7 +1304,7 @@ sub req_ci\n \n     $log->info(\"Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'\");\n \n-    $log->info(\"Created index '$work->{index}' for head $state->{module} - exit status $?\");\n+    $log->info(\"Created index '$work->{index}' for head $state->{module} - exit status $CHILD_ERROR\");\n \n     my @committedfiles = ();\n     my %oldmeta;\n@@ -1326,8 +1327,8 @@ sub req_ci\n \t# do a checkout of the file if it is part of this tree\n         if ($wrev) {\n             system('git', 'checkout-index', '-f', '-u', $filename);\n-            unless ($? == 0) {\n-                die \"Error running git-checkout-index -f -u $filename : $!\";\n+            unless ($CHILD_ERROR == 0) {\n+                die \"Error running git-checkout-index -f -u $filename : $ERRNO\";\n             }\n         }\n \n@@ -1357,7 +1358,7 @@ sub req_ci\n \n             # Calculate modes to remove\n             my $invmode = \"\";\n-            foreach ( qw (r w x) ) { $invmode .= $_ unless ( $state->{entries}{$filename}{modified_mode} =~ /$_/ ); }\n+            foreach ( qw (r w x) ) { $invmode .= $ARG unless ( $state->{entries}{$filename}{modified_mode} =~ /$ARG/ ); }\n \n             $log->debug(\"chmod u+\" . $state->{entries}{$filename}{modified_mode} . \"-\" . $invmode . \" $filename\");\n             system(\"chmod\",\"u+\" .  $state->{entries}{$filename}{modified_mode} . \"-\" . $invmode, $filename);\n@@ -1387,7 +1388,7 @@ sub req_ci\n         return;\n     }\n \n-    my $treehash = `git write-tree`;\n+    my $treehash = qx( git write-tree );\n     chomp $treehash;\n \n     $log->debug(\"Treehash : $treehash, Parenthash : $parenthash\");\n@@ -1404,7 +1405,7 @@ sub req_ci\n     }\n     close $msg_fh;\n \n-    my $commithash = `git commit-tree $treehash -p $parenthash < $msg_filename`;\n+    my $commithash = qx( git commit-tree $treehash -p $parenthash < $msg_filename );\n     chomp($commithash);\n     $log->info(\"Commit hash : $commithash\");\n \n@@ -1441,13 +1442,13 @@ sub req_ci\n \t### Emulate git-receive-pack by running hooks/post-receive\n \tmy $hook = $ENV{GIT_DIR}.'hooks/post-receive';\n \tif( -x $hook ) {\n-\t\topen(my $pipe, \"| $hook\") || die \"can't fork $!\";\n+\t\topen(my $pipe, \"| $hook\") || die \"can't fork $ERRNO\";\n \n \t\tlocal $SIG{PIPE} = sub { die 'pipe broke' };\n \n \t\tprint $pipe \"$parenthash $commithash refs/heads/$state->{module}\\n\";\n \n-\t\tclose $pipe || die \"bad pipe: $! $?\";\n+\t\tclose $pipe || die \"bad pipe: $ERRNO $CHILD_ERROR\";\n \t}\n \n     $updater->update();\n@@ -1723,7 +1724,7 @@ sub req_diff\n \n         while ( <$fh> )\n         {\n-            print \"M $_\";\n+            print \"M $ARG\";\n         }\n         close $fh;\n     }\n@@ -1858,17 +1859,17 @@ sub req_annotate\n \t# to look up the commithash in sqlite (still good to default to\n \t# the current head as we do now)\n \tsystem(\"git\", \"read-tree\", $lastseenin);\n-\tunless ($? == 0)\n+\tunless ($CHILD_ERROR == 0)\n \t{\n-\t    print \"E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $!\\n\";\n+\t    print \"E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $ERRNO\\n\";\n \t    return;\n \t}\n-\t$log->info(\"Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $?\");\n+\t$log->info(\"Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $CHILD_ERROR\");\n \n         # do a checkout of the file\n         system('git', 'checkout-index', '-f', '-u', $filename);\n-        unless ($? == 0) {\n-            print \"E error running git-checkout-index -f -u $filename : $!\\n\";\n+        unless ($CHILD_ERROR == 0) {\n+            print \"E error running git-checkout-index -f -u $filename : $ERRNO\\n\";\n             return;\n         }\n \n@@ -1881,7 +1882,7 @@ sub req_annotate\n \n         my $a_hints = \"$work->{workDir}/.annotate_hints\";\n         if (!open(ANNOTATEHINTS, '>', $a_hints)) {\n-            print \"E failed to open '$a_hints' for writing: $!\\n\";\n+            print \"E failed to open '$a_hints' for writing: $ERRNO\\n\";\n             return;\n         }\n         for (my $i=0; $i < @$revisions; $i++)\n@@ -1895,11 +1896,11 @@ sub req_annotate\n \n         print ANNOTATEHINTS \"\\n\";\n         close ANNOTATEHINTS\n-            or (print \"E failed to write $a_hints: $!\\n\"), return;\n+            or (print \"E failed to write $a_hints: $ERRNO\\n\"), return;\n \n         my @cmd = (qw(git annotate -l -S), $a_hints, $filename);\n         if (!open(ANNOTATE, \"-|\", @cmd)) {\n-            print \"E error invoking \". join(' ',@cmd) .\": $!\\n\";\n+            print \"E error invoking \". join(' ',@cmd) .\": $ERRNO\\n\";\n             return;\n         }\n         my $metadata = {};\n@@ -1924,7 +1925,7 @@ sub req_annotate\n                     $data\n                 );\n             } else {\n-                $log->warn(\"Error in annotate output! LINE: $_\");\n+                $log->warn(\"Error in annotate output! LINE: $ARG\");\n                 print \"E Annotate error \\n\";\n                 next;\n             }\n@@ -2114,12 +2115,12 @@ sub transmitfile\n \n     die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ );\n \n-    my $type = `git cat-file -t $filehash`;\n+    my $type = qx( git cat-file -t $filehash );\n     chomp $type;\n \n     die ( \"Invalid type '$type' (expected 'blob')\" ) unless ( defined ( $type ) and $type eq \"blob\" );\n \n-    my $size = `git cat-file -s $filehash`;\n+    my $size = qx( git cat-file -s $filehash );\n     chomp $size;\n \n     $log->debug(\"transmitfile($filehash) size=$size, type=$type\");\n@@ -2129,22 +2130,22 @@ sub transmitfile\n         if ( defined ( $options->{targetfile} ) )\n         {\n             my $targetfile = $options->{targetfile};\n-            open NEWFILE, \">\", $targetfile or die(\"Couldn't open '$targetfile' for writing : $!\");\n-            print NEWFILE $_ while ( <$fh> );\n-            close NEWFILE or die(\"Failed to write '$targetfile': $!\");\n+            open NEWFILE, \">\", $targetfile or die(\"Couldn't open '$targetfile' for writing : $ERRNO\");\n+            print NEWFILE $ARG while ( <$fh> );\n+            close NEWFILE or die(\"Failed to write '$targetfile': $ERRNO\");\n         } elsif ( defined ( $options->{print} ) && $options->{print} ) {\n             while ( <$fh> ) {\n                 if( /\\n\\z/ ) {\n-                    print 'M ', $_;\n+                    print 'M ', $ARG;\n                 } else {\n-                    print 'MT text ', $_, \"\\n\";\n+                    print 'MT text ', $ARG, \"\\n\";\n                 }\n             }\n         } else {\n             print \"$size\\n\";\n             print while ( <$fh> );\n         }\n-        close $fh or die (\"Couldn't close filehandle for transmitfile(): $!\");\n+        close $fh or die (\"Couldn't close filehandle for transmitfile(): $ERRNO\");\n     } else {\n         die(\"Couldn't execute git-cat-file\");\n     }\n@@ -2238,10 +2239,10 @@ sub setupWorkTree\n     if($ver)\n     {\n         system(\"git\",\"read-tree\",$ver);\n-        unless ($? == 0)\n+        unless ($CHILD_ERROR == 0)\n         {\n             $log->warn(\"Error running git-read-tree\");\n-            die \"Error running git-read-tree $ver in $work->{workDir} $!\\n\";\n+            die \"Error running git-read-tree $ver in $work->{workDir} $ERRNO\\n\";\n         }\n     }\n     # else # req_annotate reads tree for each file\n@@ -2272,7 +2273,7 @@ sub ensureWorkTree\n     chdir $work->{emptyDir} or\n         die \"Unable to chdir to $work->{emptyDir}\\n\";\n \n-    my $ver = `git show-ref -s refs/heads/$state->{module}`;\n+    my $ver = qx( git show-ref -s refs/heads/$state->{module} );\n     chomp $ver;\n     if ($ver !~ /^[0-9a-f]{40}$/)\n     {\n@@ -2292,9 +2293,9 @@ sub ensureWorkTree\n     $work->{state} = 1;\n \n     system(\"git\",\"read-tree\",$ver);\n-    unless ($? == 0)\n+    unless ($CHILD_ERROR == 0)\n     {\n-        die \"Error running git-read-tree $ver $!\\n\";\n+        die \"Error running git-read-tree $ver $ERRNO\\n\";\n     }\n }\n \n@@ -2530,8 +2531,8 @@ sub open_blob_or_die\n     {\n         if( !open $fh,\"<\",$name )\n         {\n-            $log->warn(\"Unable to open file $name: $!\");\n-            die \"Unable to open file $name: $!\\n\";\n+            $log->warn(\"Unable to open file $name: $ERRNO\");\n+            die \"Unable to open file $name: $ERRNO\\n\";\n         }\n     }\n     elsif( $srcType eq \"sha1\" || $srcType eq \"sha1Or-k\" )\n@@ -2542,7 +2543,7 @@ sub open_blob_or_die\n             die \"Need filehash\\n\";\n         }\n \n-        my $type = `git cat-file -t $name`;\n+        my $type = qx( git cat-file -t $name );\n         chomp $type;\n \n         unless ( defined ( $type ) and $type eq \"blob\" )\n@@ -2551,7 +2552,7 @@ sub open_blob_or_die\n             die ( \"Invalid type '$type' (expected 'blob')\" )\n         }\n \n-        my $size = `git cat-file -s $name`;\n+        my $size = qx( git cat-file -s $name );\n         chomp $size;\n \n         $log->debug(\"open_blob_or_die($name) size=$size, type=$type\");\n@@ -2634,7 +2635,7 @@ sub new\n \n     if ( defined ( $filename ) )\n     {\n-        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $!\");\n+        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $ERRNO\");\n     }\n \n     return $self;\n@@ -2654,7 +2655,7 @@ sub setfile\n \n     if ( defined ( $filename ) )\n     {\n-        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $!\");\n+        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $ERRNO\");\n     }\n \n     return unless ( defined ( $self->{buffer} ) and ref $self->{buffer} eq \"ARRAY\" );\n@@ -2940,10 +2941,10 @@ sub update\n     # first lets get the commit list\n     $ENV{GIT_DIR} = $self->{git_path};\n \n-    my $commitsha1 = `git rev-parse $self->{module}`;\n+    my $commitsha1 = qx( git rev-parse $self->{module} );\n     chomp $commitsha1;\n \n-    my $commitinfo = `git cat-file commit $self->{module} 2>&1`;\n+    my $commitinfo = qx( git cat-file commit $self->{module} 2>&1 );\n     unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{40}/ )\n     {\n         die(\"Invalid module '$self->{module}'\");\n@@ -2971,7 +2972,7 @@ sub update\n         push @git_log_params, $self->{module};\n     }\n     # git-rev-list is the backend / plumbing version of git-log\n-    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die \"Cannot call git-rev-list: $!\";\n+    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die \"Cannot call git-rev-list: $ERRNO\";\n \n     my @commits;\n \n@@ -3004,7 +3005,7 @@ sub update\n                 next;\n             }\n             s/^\\s+//; s/\\s+$//; # trim ws\n-            $commit{message} .= $_ . \"\\n\";\n+            $commit{message} .= $ARG . \"\\n\";\n         }\n     }\n     close GITLOG;\n@@ -3063,14 +3064,14 @@ sub update\n \t\t    # The two branches may not be related at all,\n \t\t    # in which case merge base simply fails to find\n \t\t    # any, but that's Ok.\n-\t\t    next if ($@);\n+\t\t    next if ($EVAL_ERROR);\n \n                     chomp $base;\n                     if ($base) {\n                         my @merged;\n                         # print \"want to log between  $base $parent \\n\";\n                         open(GITLOG, '-|', 'git', 'log', '--pretty=medium', \"$base..$parent\")\n-\t\t\t  or die \"Cannot call git-log: $!\";\n+\t\t\t  or die \"Cannot call git-log: $ERRNO\";\n                         my $mergedhash;\n                         while (<GITLOG>) {\n                             chomp;\n@@ -3111,14 +3112,14 @@ sub update\n \n         if ( defined ( $lastpicked ) )\n         {\n-            my $filepipe = open(FILELIST, '-|', 'git', 'diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die(\"Cannot call git-diff-tree : $!\");\n+            my $filepipe = open(FILELIST, '-|', 'git', 'diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die(\"Cannot call git-diff-tree : $ERRNO\");\n \t    local ($/) = \"\\0\";\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n                 unless ( /^:\\d{6}\\s+\\d{3}(\\d)\\d{2}\\s+[a-zA-Z0-9]{40}\\s+([a-zA-Z0-9]{40})\\s+(\\w)$/o )\n                 {\n-                    die(\"Couldn't process git-diff-tree line : $_\");\n+                    die(\"Couldn't process git-diff-tree line : $ARG\");\n                 }\n \t\tmy ($mode, $hash, $change) = ($1, $2, $3);\n \t\tmy $name = <FILELIST>;\n@@ -3185,14 +3186,14 @@ sub update\n             # this is used to detect files removed from the repo\n             my $seen_files = {};\n \n-            my $filepipe = open(FILELIST, '-|', 'git', 'ls-tree', '-z', '-r', $commit->{hash}) or die(\"Cannot call git-ls-tree : $!\");\n+            my $filepipe = open(FILELIST, '-|', 'git', 'ls-tree', '-z', '-r', $commit->{hash}) or die(\"Cannot call git-ls-tree : $ERRNO\");\n \t    local $/ = \"\\0\";\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n                 unless ( /^(\\d+)\\s+(\\w+)\\s+([a-zA-Z0-9]+)\\t(.*)$/o )\n                 {\n-                    die(\"Couldn't process git-ls-tree line : $_\");\n+                    die(\"Couldn't process git-ls-tree line : $ARG\");\n                 }\n \n                 my ( $git_perms, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 );\n@@ -3556,7 +3557,7 @@ sub in_array\n \n =head2 safe_pipe_capture\n \n-an alternative to `command` that allows input to be passed as an array\n+an alternative to qx(command) that allows input to be passed as an array\n to work around shell problems with weird characters in arguments\n \n =cut\n@@ -3566,9 +3567,9 @@ sub safe_pipe_capture {\n \n     if (my $pid = open my $child, '-|') {\n         @output = (<$child>);\n-        close $child or die join(' ',@_).\": $! $?\";\n+        close $child or die join(' ',@_).\": $ERRNO $CHILD_ERROR\";\n     } else {\n-        exec(@_) or die \"$! $?\"; # exec() can fail the executable can't be found\n+        exec(@_) or die \"$ERRNO $CHILD_ERROR\"; # exec() can fail the executable can't be found\n     }\n     return wantarray ? @output : join('',@output);\n }\n-- \n1.7.0\n"},{"id":"139675","messageId":"8639yve4gk.fsf@red.stonehenge.com","threadId":"23493","inReplyTo":"1271435565-32370-1-git-send-email-jari.aalto@cante.net","subject":"Re: [PATCH] git-cvsserver.perl: encourage use of English module and qx() operator","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2010-04-16T16:40:11Z","receivedAt":"2010-04-16T16:40:11Z","isPatch":true,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"jari\" == jari aalto <jari.aalto@cante.net> writes:\n\njari> Substitute magic variables $<puctuation> with the English.pm\n\nPlease no.\n\nThat might have been good advice in 2005, but it's crazy talk now.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion\n"},{"id":"139684","messageId":"87mxx3qr6y.fsf@jondo.cante.net","threadId":"23493","inReplyTo":"8639yve4gk.fsf@red.stonehenge.com","subject":"Re: [PATCH] git-cvsserver.perl: encourage use of English module and qx() operator","fromName":"Jari Aalto","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-16T16:48:21Z","receivedAt":"2010-04-16T16:48:21Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"merlyn@stonehenge.com (Randal L. Schwartz) writes:\n\n>>>>>> \"jari\" == jari aalto <jari.aalto@cante.net> writes:\n>\n> jari> Substitute magic variables $<puctuation> with the English.pm\n>\n> Please no.\n>\n> That might have been good advice in 2005, but it's crazy talk now.\n\nIt would be interesting to know why not. These magic variables are hard\nto read and remember without consulting the manual pages.\n\nThere doesn't seem to be noticeable performance penalty any more:\n\n    $ perl --version | grep v5\n    This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi\n\n    $ time perl -e 'use English qw( -no_match_vars ); print'\n\n    real    0m0.016s\n    user    0m0.008s\n    sys     0m0.004s\n\n    $ time perl -e 'print 1'\n\n    real    0m0.005s\n    user    0m0.000s\n    sys     0m0.004s\n\nJari\n"},{"id":"139685","messageId":"86y6gncp69.fsf@red.stonehenge.com","threadId":"23493","inReplyTo":"87mxx3qr6y.fsf@jondo.cante.net","subject":"Re: [PATCH] git-cvsserver.perl: encourage use of English module and qx() operator","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2010-04-16T16:55:42Z","receivedAt":"2010-04-16T16:55:42Z","isPatch":true,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Jari\" == Jari Aalto <jari.aalto@cante.net> writes:\n\nJari> It would be interesting to know why not. These magic variables are hard\nJari> to read and remember without consulting the manual pages.\n\nBecause it was observed over time that the aliases were *also* hard to\nremember without consulting the manpages. :)\n\nSo you were merely trading one problem for another, and since far more\ncode is out there that does *not* use English than does, we agreed that\nuse English was an interesting but failed experiment.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion\n"},{"id":"139693","messageId":"a72bb6e879d892c6d84a0e84056971b30491a972.1271438647.git.jari.aalto@cante.net","threadId":"23493","inReplyTo":"1271435565-32370-1-git-send-email-jari.aalto@cante.net","subject":"[PATCH v2] git-cvsserver.perl: encourage use of English module and qx() operator","fromName":"","fromEmail":"jari.aalto@cante.net","sentAt":"2010-04-16T17:24:27Z","receivedAt":"2010-04-16T17:24:27Z","isPatch":true,"sender":{"key":"jari.aalto@cante.net","avatar":"https://avatars.githubusercontent.com/u/34601?v=4"},"body":"From: Jari Aalto <jari.aalto@cante.net>\n\nSubstitute $<punctuation> magic variables with the English.pm\nequivalents for readability. Likewise substitute backtics with the\nalternative qx() for system calls.\n\nSigned-off-by: Jari Aalto <jari.aalto@cante.net>\n---\n git-cvsserver.perl |  151 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 76 insertions(+), 75 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 13751db..9185237 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -19,6 +19,7 @@ use strict;\n use warnings;\n use bytes;\n \n+use English ; # qw( -no_match_vars );\n use Fcntl;\n use File::Temp qw/tempdir tempfile/;\n use File::Path qw/rmtree/;\n@@ -46,7 +47,7 @@ my $DATE_LIST = {\n };\n \n # Enable autoflush for STDOUT (otherwise the whole thing falls apart)\n-$| = 1;\n+$OUTPUT_AUTOFLUSH = 1;\n \n #### Definition and mappings of functions ####\n \n@@ -214,8 +215,8 @@ while (<STDIN>)\n         # we're fairly screwed because we don't know if the client is expecting\n         # a response. If it is, the client will hang, we'll hang, and the whole\n         # thing will be custard.\n-        $log->fatal(\"Don't understand command $_\\n\");\n-        die(\"Unknown command $_\");\n+        $log->fatal(\"Don't understand command $ARG\\n\");\n+        die(\"Unknown command $ARG\");\n     }\n }\n \n@@ -305,8 +306,8 @@ sub req_Root\n        return 0;\n     }\n \n-    my @gitvars = `git config -l`;\n-    if ($?) {\n+    my @gitvars = qx( git config -l );\n+    if ($CHILD_ERROR) {\n        print \"E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\\n\";\n         print \"E \\n\";\n         print \"error 1 - problem executing git-config\\n\";\n@@ -538,19 +539,19 @@ sub req_add\n \n         unless ( defined ( $state->{entries}{$filename}{modified_filename} ) )\n         {\n-            print \"E cvs add: nothing known about `$filename'\\n\";\n+            print \"E cvs add: nothing known about '$filename'\\n\";\n             next;\n         }\n         # TODO : check we're not squashing an already existing file\n         if ( defined ( $state->{entries}{$filename}{revision} ) )\n         {\n-            print \"E cvs add: `$filename' has already been entered\\n\";\n+            print \"E cvs add: '$filename' has already been entered\\n\";\n             next;\n         }\n \n         my ( $filepart, $dirpart ) = filenamesplit($filename, 1);\n \n-        print \"E cvs add: scheduling file `$filename' for addition\\n\";\n+        print \"E cvs add: scheduling file '$filename' for addition\\n\";\n \n         print \"Checked-in $dirpart\\n\";\n         print \"$filename\\n\";\n@@ -579,11 +580,11 @@ sub req_add\n \n     if ( $addcount == 1 )\n     {\n-        print \"E cvs add: use `cvs commit' to add this file permanently\\n\";\n+        print \"E cvs add: use 'cvs commit' to add this file permanently\\n\";\n     }\n     elsif ( $addcount > 1 )\n     {\n-        print \"E cvs add: use `cvs commit' to add these files permanently\\n\";\n+        print \"E cvs add: use 'cvs commit' to add these files permanently\\n\";\n     }\n \n     print \"ok\\n\";\n@@ -620,7 +621,7 @@ sub req_remove\n \n         if ( defined ( $state->{entries}{$filename}{unchanged} ) or defined ( $state->{entries}{$filename}{modified_filename} ) )\n         {\n-            print \"E cvs remove: file `$filename' still in working directory\\n\";\n+            print \"E cvs remove: file '$filename' still in working directory\\n\";\n             next;\n         }\n \n@@ -629,27 +630,27 @@ sub req_remove\n \n         unless ( defined ( $wrev ) )\n         {\n-            print \"E cvs remove: nothing known about `$filename'\\n\";\n+            print \"E cvs remove: nothing known about '$filename'\\n\";\n             next;\n         }\n \n         if ( defined($wrev) and $wrev < 0 )\n         {\n-            print \"E cvs remove: file `$filename' already scheduled for removal\\n\";\n+            print \"E cvs remove: file '$filename' already scheduled for removal\\n\";\n             next;\n         }\n \n         unless ( $wrev == $meta->{revision} )\n         {\n             # TODO : not sure if the format of this message is quite correct.\n-            print \"E cvs remove: Up to date check failed for `$filename'\\n\";\n+            print \"E cvs remove: Up to date check failed for '$filename'\\n\";\n             next;\n         }\n \n \n         my ( $filepart, $dirpart ) = filenamesplit($filename, 1);\n \n-        print \"E cvs remove: scheduling `$filename' for removal\\n\";\n+        print \"E cvs remove: scheduling '$filename' for removal\\n\";\n \n         print \"Checked-in $dirpart\\n\";\n         print \"$filename\\n\";\n@@ -661,11 +662,11 @@ sub req_remove\n \n     if ( $rmcount == 1 )\n     {\n-        print \"E cvs remove: use `cvs commit' to remove this file permanently\\n\";\n+        print \"E cvs remove: use 'cvs commit' to remove this file permanently\\n\";\n     }\n     elsif ( $rmcount > 1 )\n     {\n-        print \"E cvs remove: use `cvs commit' to remove these files permanently\\n\";\n+        print \"E cvs remove: use 'cvs commit' to remove these files permanently\\n\";\n     }\n \n     print \"ok\\n\";\n@@ -709,7 +710,7 @@ sub req_Modified\n     }\n \n     close $fh\n-        or (print \"E failed to write temporary, $filename: $!\\n\"), return;\n+        or (print \"E failed to write temporary, $filename: $ERRNO\\n\"), return;\n \n     # Ensure we have something sensible for the file mode\n     if ( $mode =~ /u=(\\w+)/ )\n@@ -722,7 +723,7 @@ sub req_Modified\n     # Save the file data in $state\n     $state->{entries}{$state->{directory}.$data}{modified_filename} = $filename;\n     $state->{entries}{$state->{directory}.$data}{modified_mode} = $mode;\n-    $state->{entries}{$state->{directory}.$data}{modified_hash} = `git hash-object $filename`;\n+    $state->{entries}{$state->{directory}.$data}{modified_hash} = qx( git hash-object $filename );\n     $state->{entries}{$state->{directory}.$data}{modified_hash} =~ s/\\s.*$//s;\n \n     #$log->debug(\"req_Modified : file=$data mode=$mode size=$size\");\n@@ -824,7 +825,7 @@ sub req_co\n \n     # Provide list of modules, if -c was used.\n     if (exists $state->{opt}{c}) {\n-        my $showref = `git show-ref --heads`;\n+        my $showref = qx( git show-ref --heads );\n         for my $line (split '\\n', $showref) {\n             if ( $line =~ m% refs/heads/(.*)$% ) {\n                 print \"M $1\\t$1\\n\";\n@@ -980,11 +981,11 @@ sub req_update\n     # projects (heads in this case) to checkout.\n     #\n     if ($state->{module} eq '') {\n-        my $showref = `git show-ref --heads`;\n+        my $showref = qx( git show-ref --heads );\n         print \"E cvs update: Updating .\\n\";\n         for my $line (split '\\n', $showref) {\n             if ( $line =~ m% refs/heads/(.*)$% ) {\n-                print \"E cvs update: New directory `$1'\\n\";\n+                print \"E cvs update: New directory '$1'\\n\";\n             }\n         }\n         print \"ok\\n\";\n@@ -1101,7 +1102,7 @@ sub req_update\n \n             $log->info(\"Removing '$filename' from working copy (no longer in the repo)\");\n \n-            print \"E cvs update: `$filename' is no longer in the repository\\n\";\n+            print \"E cvs update: '$filename' is no longer in the repository\\n\";\n             # Don't want to actually _DO_ the update if -n specified\n             unless ( $state->{globaloptions}{-n} ) {\n \t\tprint \"Removed $dirpart\\n\";\n@@ -1249,7 +1250,7 @@ sub req_update\n                 # transmit file, format is single integer on a line by itself (file\n                 # size) followed by the file contents\n                 # TODO : we should copy files in blocks\n-                my $data = `cat $mergedFile`;\n+                my $data = qx( cat $mergedFile );\n                 $log->debug(\"File size : \" . length($data));\n                 print length($data) . \"\\n\";\n                 print $data;\n@@ -1291,7 +1292,7 @@ sub req_ci\n     $updater->update();\n \n     # Remember where the head was at the beginning.\n-    my $parenthash = `git show-ref -s refs/heads/$state->{module}`;\n+    my $parenthash = qx( git show-ref -s refs/heads/$state->{module} );\n     chomp $parenthash;\n     if ($parenthash !~ /^[0-9a-f]{40}$/) {\n \t    print \"error 1 pserver cannot find the current HEAD of module\";\n@@ -1303,7 +1304,7 @@ sub req_ci\n \n     $log->info(\"Lockless commit start, basing commit on '$work->{workDir}', index file is '$work->{index}'\");\n \n-    $log->info(\"Created index '$work->{index}' for head $state->{module} - exit status $?\");\n+    $log->info(\"Created index '$work->{index}' for head $state->{module} - exit status $CHILD_ERROR\");\n \n     my @committedfiles = ();\n     my %oldmeta;\n@@ -1326,8 +1327,8 @@ sub req_ci\n \t# do a checkout of the file if it is part of this tree\n         if ($wrev) {\n             system('git', 'checkout-index', '-f', '-u', $filename);\n-            unless ($? == 0) {\n-                die \"Error running git-checkout-index -f -u $filename : $!\";\n+            unless ($CHILD_ERROR == 0) {\n+                die \"Error running git-checkout-index -f -u $filename : $ERRNO\";\n             }\n         }\n \n@@ -1357,7 +1358,7 @@ sub req_ci\n \n             # Calculate modes to remove\n             my $invmode = \"\";\n-            foreach ( qw (r w x) ) { $invmode .= $_ unless ( $state->{entries}{$filename}{modified_mode} =~ /$_/ ); }\n+            foreach ( qw (r w x) ) { $invmode .= $ARG unless ( $state->{entries}{$filename}{modified_mode} =~ /$ARG/ ); }\n \n             $log->debug(\"chmod u+\" . $state->{entries}{$filename}{modified_mode} . \"-\" . $invmode . \" $filename\");\n             system(\"chmod\",\"u+\" .  $state->{entries}{$filename}{modified_mode} . \"-\" . $invmode, $filename);\n@@ -1387,7 +1388,7 @@ sub req_ci\n         return;\n     }\n \n-    my $treehash = `git write-tree`;\n+    my $treehash = qx( git write-tree );\n     chomp $treehash;\n \n     $log->debug(\"Treehash : $treehash, Parenthash : $parenthash\");\n@@ -1404,7 +1405,7 @@ sub req_ci\n     }\n     close $msg_fh;\n \n-    my $commithash = `git commit-tree $treehash -p $parenthash < $msg_filename`;\n+    my $commithash = qx( git commit-tree $treehash -p $parenthash < $msg_filename );\n     chomp($commithash);\n     $log->info(\"Commit hash : $commithash\");\n \n@@ -1441,13 +1442,13 @@ sub req_ci\n \t### Emulate git-receive-pack by running hooks/post-receive\n \tmy $hook = $ENV{GIT_DIR}.'hooks/post-receive';\n \tif( -x $hook ) {\n-\t\topen(my $pipe, \"| $hook\") || die \"can't fork $!\";\n+\t\topen(my $pipe, \"| $hook\") || die \"can't fork $ERRNO\";\n \n \t\tlocal $SIG{PIPE} = sub { die 'pipe broke' };\n \n \t\tprint $pipe \"$parenthash $commithash refs/heads/$state->{module}\\n\";\n \n-\t\tclose $pipe || die \"bad pipe: $! $?\";\n+\t\tclose $pipe || die \"bad pipe: $ERRNO $CHILD_ERROR\";\n \t}\n \n     $updater->update();\n@@ -1723,7 +1724,7 @@ sub req_diff\n \n         while ( <$fh> )\n         {\n-            print \"M $_\";\n+            print \"M $ARG\";\n         }\n         close $fh;\n     }\n@@ -1858,17 +1859,17 @@ sub req_annotate\n \t# to look up the commithash in sqlite (still good to default to\n \t# the current head as we do now)\n \tsystem(\"git\", \"read-tree\", $lastseenin);\n-\tunless ($? == 0)\n+\tunless ($CHILD_ERROR == 0)\n \t{\n-\t    print \"E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $!\\n\";\n+\t    print \"E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $ERRNO\\n\";\n \t    return;\n \t}\n-\t$log->info(\"Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $?\");\n+\t$log->info(\"Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $CHILD_ERROR\");\n \n         # do a checkout of the file\n         system('git', 'checkout-index', '-f', '-u', $filename);\n-        unless ($? == 0) {\n-            print \"E error running git-checkout-index -f -u $filename : $!\\n\";\n+        unless ($CHILD_ERROR == 0) {\n+            print \"E error running git-checkout-index -f -u $filename : $ERRNO\\n\";\n             return;\n         }\n \n@@ -1881,7 +1882,7 @@ sub req_annotate\n \n         my $a_hints = \"$work->{workDir}/.annotate_hints\";\n         if (!open(ANNOTATEHINTS, '>', $a_hints)) {\n-            print \"E failed to open '$a_hints' for writing: $!\\n\";\n+            print \"E failed to open '$a_hints' for writing: $ERRNO\\n\";\n             return;\n         }\n         for (my $i=0; $i < @$revisions; $i++)\n@@ -1895,11 +1896,11 @@ sub req_annotate\n \n         print ANNOTATEHINTS \"\\n\";\n         close ANNOTATEHINTS\n-            or (print \"E failed to write $a_hints: $!\\n\"), return;\n+            or (print \"E failed to write $a_hints: $ERRNO\\n\"), return;\n \n         my @cmd = (qw(git annotate -l -S), $a_hints, $filename);\n         if (!open(ANNOTATE, \"-|\", @cmd)) {\n-            print \"E error invoking \". join(' ',@cmd) .\": $!\\n\";\n+            print \"E error invoking \". join(' ',@cmd) .\": $ERRNO\\n\";\n             return;\n         }\n         my $metadata = {};\n@@ -1924,7 +1925,7 @@ sub req_annotate\n                     $data\n                 );\n             } else {\n-                $log->warn(\"Error in annotate output! LINE: $_\");\n+                $log->warn(\"Error in annotate output! LINE: $ARG\");\n                 print \"E Annotate error \\n\";\n                 next;\n             }\n@@ -2114,12 +2115,12 @@ sub transmitfile\n \n     die \"Need filehash\" unless ( defined ( $filehash ) and $filehash =~ /^[a-zA-Z0-9]{40}$/ );\n \n-    my $type = `git cat-file -t $filehash`;\n+    my $type = qx( git cat-file -t $filehash );\n     chomp $type;\n \n     die ( \"Invalid type '$type' (expected 'blob')\" ) unless ( defined ( $type ) and $type eq \"blob\" );\n \n-    my $size = `git cat-file -s $filehash`;\n+    my $size = qx( git cat-file -s $filehash );\n     chomp $size;\n \n     $log->debug(\"transmitfile($filehash) size=$size, type=$type\");\n@@ -2129,22 +2130,22 @@ sub transmitfile\n         if ( defined ( $options->{targetfile} ) )\n         {\n             my $targetfile = $options->{targetfile};\n-            open NEWFILE, \">\", $targetfile or die(\"Couldn't open '$targetfile' for writing : $!\");\n-            print NEWFILE $_ while ( <$fh> );\n-            close NEWFILE or die(\"Failed to write '$targetfile': $!\");\n+            open NEWFILE, \">\", $targetfile or die(\"Couldn't open '$targetfile' for writing : $ERRNO\");\n+            print NEWFILE $ARG while ( <$fh> );\n+            close NEWFILE or die(\"Failed to write '$targetfile': $ERRNO\");\n         } elsif ( defined ( $options->{print} ) && $options->{print} ) {\n             while ( <$fh> ) {\n                 if( /\\n\\z/ ) {\n-                    print 'M ', $_;\n+                    print 'M ', $ARG;\n                 } else {\n-                    print 'MT text ', $_, \"\\n\";\n+                    print 'MT text ', $ARG, \"\\n\";\n                 }\n             }\n         } else {\n             print \"$size\\n\";\n             print while ( <$fh> );\n         }\n-        close $fh or die (\"Couldn't close filehandle for transmitfile(): $!\");\n+        close $fh or die (\"Couldn't close filehandle for transmitfile(): $ERRNO\");\n     } else {\n         die(\"Couldn't execute git-cat-file\");\n     }\n@@ -2238,10 +2239,10 @@ sub setupWorkTree\n     if($ver)\n     {\n         system(\"git\",\"read-tree\",$ver);\n-        unless ($? == 0)\n+        unless ($CHILD_ERROR == 0)\n         {\n             $log->warn(\"Error running git-read-tree\");\n-            die \"Error running git-read-tree $ver in $work->{workDir} $!\\n\";\n+            die \"Error running git-read-tree $ver in $work->{workDir} $ERRNO\\n\";\n         }\n     }\n     # else # req_annotate reads tree for each file\n@@ -2272,7 +2273,7 @@ sub ensureWorkTree\n     chdir $work->{emptyDir} or\n         die \"Unable to chdir to $work->{emptyDir}\\n\";\n \n-    my $ver = `git show-ref -s refs/heads/$state->{module}`;\n+    my $ver = qx( git show-ref -s refs/heads/$state->{module} );\n     chomp $ver;\n     if ($ver !~ /^[0-9a-f]{40}$/)\n     {\n@@ -2292,9 +2293,9 @@ sub ensureWorkTree\n     $work->{state} = 1;\n \n     system(\"git\",\"read-tree\",$ver);\n-    unless ($? == 0)\n+    unless ($CHILD_ERROR == 0)\n     {\n-        die \"Error running git-read-tree $ver $!\\n\";\n+        die \"Error running git-read-tree $ver $ERRNO\\n\";\n     }\n }\n \n@@ -2530,8 +2531,8 @@ sub open_blob_or_die\n     {\n         if( !open $fh,\"<\",$name )\n         {\n-            $log->warn(\"Unable to open file $name: $!\");\n-            die \"Unable to open file $name: $!\\n\";\n+            $log->warn(\"Unable to open file $name: $ERRNO\");\n+            die \"Unable to open file $name: $ERRNO\\n\";\n         }\n     }\n     elsif( $srcType eq \"sha1\" || $srcType eq \"sha1Or-k\" )\n@@ -2542,7 +2543,7 @@ sub open_blob_or_die\n             die \"Need filehash\\n\";\n         }\n \n-        my $type = `git cat-file -t $name`;\n+        my $type = qx( git cat-file -t $name );\n         chomp $type;\n \n         unless ( defined ( $type ) and $type eq \"blob\" )\n@@ -2551,7 +2552,7 @@ sub open_blob_or_die\n             die ( \"Invalid type '$type' (expected 'blob')\" )\n         }\n \n-        my $size = `git cat-file -s $name`;\n+        my $size = qx( git cat-file -s $name );\n         chomp $size;\n \n         $log->debug(\"open_blob_or_die($name) size=$size, type=$type\");\n@@ -2634,7 +2635,7 @@ sub new\n \n     if ( defined ( $filename ) )\n     {\n-        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $!\");\n+        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $main::ERRNO\");\n     }\n \n     return $self;\n@@ -2654,7 +2655,7 @@ sub setfile\n \n     if ( defined ( $filename ) )\n     {\n-        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $!\");\n+        open $self->{fh}, \">>\", $filename or die(\"Couldn't open '$filename' for writing : $main::ERRNO\");\n     }\n \n     return unless ( defined ( $self->{buffer} ) and ref $self->{buffer} eq \"ARRAY\" );\n@@ -2940,10 +2941,10 @@ sub update\n     # first lets get the commit list\n     $ENV{GIT_DIR} = $self->{git_path};\n \n-    my $commitsha1 = `git rev-parse $self->{module}`;\n+    my $commitsha1 = qx( git rev-parse $self->{module} );\n     chomp $commitsha1;\n \n-    my $commitinfo = `git cat-file commit $self->{module} 2>&1`;\n+    my $commitinfo = qx( git cat-file commit $self->{module} 2>&1 );\n     unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{40}/ )\n     {\n         die(\"Invalid module '$self->{module}'\");\n@@ -2971,7 +2972,7 @@ sub update\n         push @git_log_params, $self->{module};\n     }\n     # git-rev-list is the backend / plumbing version of git-log\n-    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die \"Cannot call git-rev-list: $!\";\n+    open(GITLOG, '-|', 'git', 'rev-list', @git_log_params) or die \"Cannot call git-rev-list: $main::ERRNO\";\n \n     my @commits;\n \n@@ -3004,7 +3005,7 @@ sub update\n                 next;\n             }\n             s/^\\s+//; s/\\s+$//; # trim ws\n-            $commit{message} .= $_ . \"\\n\";\n+            $commit{message} .= $main::ARG . \"\\n\";\n         }\n     }\n     close GITLOG;\n@@ -3063,14 +3064,14 @@ sub update\n \t\t    # The two branches may not be related at all,\n \t\t    # in which case merge base simply fails to find\n \t\t    # any, but that's Ok.\n-\t\t    next if ($@);\n+\t\t    next if ($main::EVAL_ERROR);\n \n                     chomp $base;\n                     if ($base) {\n                         my @merged;\n                         # print \"want to log between  $base $parent \\n\";\n                         open(GITLOG, '-|', 'git', 'log', '--pretty=medium', \"$base..$parent\")\n-\t\t\t  or die \"Cannot call git-log: $!\";\n+\t\t\t  or die \"Cannot call git-log: $main::ERRNO\";\n                         my $mergedhash;\n                         while (<GITLOG>) {\n                             chomp;\n@@ -3111,14 +3112,14 @@ sub update\n \n         if ( defined ( $lastpicked ) )\n         {\n-            my $filepipe = open(FILELIST, '-|', 'git', 'diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die(\"Cannot call git-diff-tree : $!\");\n+            my $filepipe = open(FILELIST, '-|', 'git', 'diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die(\"Cannot call git-diff-tree : $main::ERRNO\");\n \t    local ($/) = \"\\0\";\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n                 unless ( /^:\\d{6}\\s+\\d{3}(\\d)\\d{2}\\s+[a-zA-Z0-9]{40}\\s+([a-zA-Z0-9]{40})\\s+(\\w)$/o )\n                 {\n-                    die(\"Couldn't process git-diff-tree line : $_\");\n+                    die(\"Couldn't process git-diff-tree line : $main::ARG\");\n                 }\n \t\tmy ($mode, $hash, $change) = ($1, $2, $3);\n \t\tmy $name = <FILELIST>;\n@@ -3185,14 +3186,14 @@ sub update\n             # this is used to detect files removed from the repo\n             my $seen_files = {};\n \n-            my $filepipe = open(FILELIST, '-|', 'git', 'ls-tree', '-z', '-r', $commit->{hash}) or die(\"Cannot call git-ls-tree : $!\");\n+            my $filepipe = open(FILELIST, '-|', 'git', 'ls-tree', '-z', '-r', $commit->{hash}) or die(\"Cannot call git-ls-tree : $main::ERRNO\");\n \t    local $/ = \"\\0\";\n             while ( <FILELIST> )\n             {\n \t\tchomp;\n                 unless ( /^(\\d+)\\s+(\\w+)\\s+([a-zA-Z0-9]+)\\t(.*)$/o )\n                 {\n-                    die(\"Couldn't process git-ls-tree line : $_\");\n+                    die(\"Couldn't process git-ls-tree line : $main::ARG\");\n                 }\n \n                 my ( $git_perms, $git_type, $git_hash, $git_filename ) = ( $1, $2, $3, $4 );\n@@ -3556,7 +3557,7 @@ sub in_array\n \n =head2 safe_pipe_capture\n \n-an alternative to `command` that allows input to be passed as an array\n+an alternative to qx(command) that allows input to be passed as an array\n to work around shell problems with weird characters in arguments\n \n =cut\n@@ -3566,9 +3567,9 @@ sub safe_pipe_capture {\n \n     if (my $pid = open my $child, '-|') {\n         @output = (<$child>);\n-        close $child or die join(' ',@_).\": $! $?\";\n+        close $child or die join(' ',@_).\": $main::ERRNO $main::CHILD_ERROR\";\n     } else {\n-        exec(@_) or die \"$! $?\"; # exec() can fail the executable can't be found\n+        exec(@_) or die \"$main::ERRNO $main::CHILD_ERROR\"; # exec() can fail the executable can't be found\n     }\n     return wantarray ? @output : join('',@output);\n }\n-- \n1.7.0\n"}]}