Update IPC-Cmd to CPAN version 0.64
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Tue, 19 Oct 2010 19:50:44 +0000 (20:50 +0100)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Tue, 19 Oct 2010 19:50:44 +0000 (20:50 +0100)
  [DELTA]

  Changes for 0.64    Tue Oct 19 19:01:05 BST 2010
  =================================================
  * Only enable the can_run instances behaviour when
    global variable $INSTANCES is set

  Changes for 0.62    Tue Oct 19 15:51:30 BST 2010
  =================================================
  * Amended can_run behaviour to run all found instances
    of the given binary in a list context

Porting/Maintainers.pl
cpan/IPC-Cmd/lib/IPC/Cmd.pm
pod/perldelta.pod

index 425ba7a..d42d548 100755 (executable)
@@ -762,7 +762,7 @@ use File::Glob qw(:case);
     'IPC::Cmd' =>
        {
        'MAINTAINER'    => 'kane',
-       'DISTRIBUTION'  => 'BINGOS/IPC-Cmd-0.60.tar.gz',
+       'DISTRIBUTION'  => 'BINGOS/IPC-Cmd-0.64.tar.gz',
        'FILES'         => q[cpan/IPC-Cmd],
        'UPSTREAM'      => 'cpan',
        },
index 8c7a87e..9cd9e97 100644 (file)
@@ -14,9 +14,10 @@ BEGIN {
     use Exporter    ();
     use vars        qw[ @ISA $VERSION @EXPORT_OK $VERBOSE $DEBUG
                         $USE_IPC_RUN $USE_IPC_OPEN3 $CAN_USE_RUN_FORKED $WARN
+                        $INSTANCES
                     ];
 
-    $VERSION        = '0.60';
+    $VERSION        = '0.64';
     $VERBOSE        = 0;
     $DEBUG          = 0;
     $WARN           = 1;
@@ -185,13 +186,17 @@ providing C<run_forked> on the current platform.
 C<can_run> takes but a single argument: the name of a binary you wish
 to locate. C<can_run> works much like the unix binary C<which> or the bash
 command C<type>, which scans through your path, looking for the requested
-binary .
+binary.
 
 Unlike C<which> and C<type>, this function is platform independent and
 will also work on, for example, Win32.
 
-It will return the full path to the binary you asked for if it was
-found, or C<undef> if it was not.
+If called in a scalar context it will return the full path to the binary
+you asked for if it was found, or C<undef> if it was not.
+
+If called in a list context and the global variable C<$INSTANCES> is a true value 
+it will return a list of the full paths to instances
+of the binary where found in C<PATH> or an empty list if it was not found.
 
 =cut
 
@@ -210,6 +215,8 @@ sub can_run {
     require File::Spec;
     require ExtUtils::MakeMaker;
 
+    my @possibles;
+
     if( File::Spec->file_name_is_absolute($command) ) {
         return MM->maybe_command($command);
 
@@ -220,9 +227,11 @@ sub can_run {
         ) {
             next if ! $dir || ! -d $dir;
             my $abs = File::Spec->catfile( IS_WIN32 ? Win32::GetShortPathName( $dir ) : $dir, $command);
-            return $abs if $abs = MM->maybe_command($abs);
+            push @possibles, $abs if $abs = MM->maybe_command($abs);
         }
     }
+    return @possibles if wantarray and $INSTANCES;
+    return shift @possibles;
 }
 
 =head2 $ok | ($ok, $err, $full_buf, $stdout_buff, $stderr_buff) = run( command => COMMAND, [verbose => BOOL, buffer => \$SCALAR, timeout => DIGIT] );
@@ -1702,6 +1711,13 @@ the failure to load an C<IPC::*> module you explicitly requested.
 
 Defaults to true. Turn this off at your own risk.
 
+=head2 $IPC::Cmd::INSTANCES
+
+This variable controls whether C<can_run> will return all instances of
+the binary it finds in the C<PATH> when called in a list context.
+
+Defaults to false, set to true to enable the described behaviour.
+
 =head1 Caveats
 
 =over 4
index 17f06b2..bc11a68 100644 (file)
@@ -307,6 +307,10 @@ C<if> has been upgraded from version 0.05 to 0.06
 
 =item *
 
+C<IPC::Cmd> has been upgraded from version 0.60 to 0.64
+
+=item *
+
 C<IPC::Open3> has been upgraded from version 1.06 to 1.07.
 
 The internal C<xclose> routine now knows how to handle file descriptors, as