diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2010-11-23 12:21:02 +0000 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2010-11-23 12:21:02 +0000 |
commit | 39b09a1b697b89ae14eb0e590e2444bb112d681a (patch) | |
tree | 50e97fbea2c998dc33093f0f292ff87ade91770e /cpan/IPC-Cmd | |
parent | 5369a12a8c1ff6b0f04ec193aaf57ad238bf76b8 (diff) | |
download | perl-39b09a1b697b89ae14eb0e590e2444bb112d681a.tar.gz |
Update IPC-Cmd to CPAN version 0.66
[DELTA]
Changes for 0.66 Tue Nov 23 12:10:24 GMT 2010
=================================================
* Apply documentation patch from Dan Dascalescu [RT # 63250]
* Apply another documentation patch from Dan Dascalescu [RT #63251]
* Fix an issue with _split_like_shell_win32() raised by tunakermit [RT #62961]
Diffstat (limited to 'cpan/IPC-Cmd')
-rw-r--r-- | cpan/IPC-Cmd/lib/IPC/Cmd.pm | 137 |
1 files changed, 68 insertions, 69 deletions
diff --git a/cpan/IPC-Cmd/lib/IPC/Cmd.pm b/cpan/IPC-Cmd/lib/IPC/Cmd.pm index 9cd9e972be..3ac438e3f3 100644 --- a/cpan/IPC-Cmd/lib/IPC/Cmd.pm +++ b/cpan/IPC-Cmd/lib/IPC/Cmd.pm @@ -17,7 +17,7 @@ BEGIN { $INSTANCES ]; - $VERSION = '0.64'; + $VERSION = '0.66'; $VERBOSE = 0; $DEBUG = 0; $WARN = 1; @@ -76,7 +76,7 @@ IPC::Cmd - finding and running system commands made easy ### in list context ### - my( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = + my( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); if( $success ) { @@ -96,8 +96,8 @@ IPC::Cmd - finding and running system commands made easy =head1 DESCRIPTION -IPC::Cmd allows you to run commands, interactively if desired, -platform independent but have them still work. +IPC::Cmd allows you to run commands platform independently, +interactively if desired, but have them still work. The C<can_run> function can tell you if a certain binary is installed and if so where, whereas the C<run> function can actually execute any @@ -109,8 +109,8 @@ as adhere to your verbosity settings. =head2 $ipc_run_version = IPC::Cmd->can_use_ipc_run( [VERBOSE] ) Utility function that tells you if C<IPC::Run> is available. -If the verbose flag is passed, it will print diagnostic messages -if C<IPC::Run> can not be found or loaded. +If the C<verbose> flag is passed, it will print diagnostic messages +if L<IPC::Run> can not be found or loaded. =cut @@ -119,7 +119,7 @@ sub can_use_ipc_run { my $self = shift; my $verbose = shift || 0; - ### ipc::run doesn't run on win98 + ### IPC::Run doesn't run on win98 return if IS_WIN98; ### if we dont have ipc::run, we obviously can't use it. @@ -145,11 +145,10 @@ sub can_use_ipc_open3 { my $self = shift; my $verbose = shift || 0; - ### ipc::open3 is not working on VMS becasue of a lack of fork. - ### XXX todo, win32 also does not have fork, so need to do more research. + ### IPC::Open3 is not working on VMS because of a lack of fork. return if IS_VMS; - ### ipc::open3 works on every non-VMS platform platform, but it can't + ### IPC::Open3 works on every non-VMS platform platform, but it can't ### capture buffers on win32 :( return unless can_load( modules => { map {$_ => '0.0'} qw|IPC::Open3 IO::Select Symbol| }, @@ -183,7 +182,7 @@ providing C<run_forked> on the current platform. =head2 $path = can_run( PROGRAM ); -C<can_run> takes but a single argument: the name of a binary you wish +C<can_run> takes only one 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. @@ -194,9 +193,9 @@ will also work on, for example, Win32. 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. +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 @@ -246,15 +245,15 @@ This is the command to execute. It may be either a string or an array reference. This is a required argument. -See L<CAVEATS> for remarks on how commands are parsed and their +See L<"Caveats"> for remarks on how commands are parsed and their limitations. =item verbose This controls whether all output of a command should also be printed to STDOUT/STDERR or should only be trapped in buffers (NOTE: buffers -require C<IPC::Run> to be installed or your system able to work with -C<IPC::Open3>). +require L<IPC::Run> to be installed, or your system able to work with +L<IPC::Open3>). It will default to the global setting of C<$IPC::Cmd::VERBOSE>, which by default is 0. @@ -269,14 +268,14 @@ If you require this distinction, run the C<run> command in list context and inspect the individual buffers. Of course, this requires that the underlying call supports buffers. See -the note on buffers right above. +the note on buffers above. =item timeout Sets the maximum time the command is allowed to run before aborting, using the built-in C<alarm()> call. If the timeout is triggered, the C<errorcode> in the return value will be set to an object of the -C<IPC::Cmd::TimeOut> class. See the C<errorcode> section below for +C<IPC::Cmd::TimeOut> class. See the L<"error message"> section below for details. Defaults to C<0>, meaning no timeout is set. @@ -296,7 +295,7 @@ not. =item error message -If the first element of the return value (success) was 0, then some +If the first element of the return value (C<success>) was 0, then some error occurred. This second element is the error message the command you requested exited with, if available. This is generally a pretty printed value of C<$?> or C<$@>. See C<perldoc perlvar> for details on @@ -306,31 +305,26 @@ the string C<IPC::Cmd::TimeOut>, the timeout class. =item full_buffer -This is an arrayreference containing all the output the command +This is an array reference containing all the output the command generated. -Note that buffers are only available if you have C<IPC::Run> installed, -or if your system is able to work with C<IPC::Open3> -- See below). -This element will be C<undef> if this is not the case. +Note that buffers are only available if you have L<IPC::Run> installed, +or if your system is able to work with L<IPC::Open3> -- see below). +Otherwise, this element will be C<undef>. =item out_buffer -This is an arrayreference containing all the output sent to STDOUT the -command generated. -Note that buffers are only available if you have C<IPC::Run> installed, -or if your system is able to work with C<IPC::Open3> -- See below). -This element will be C<undef> if this is not the case. +This is an array reference containing all the output sent to STDOUT the +command generated. The notes from L<"full_buffer"> apply. =item error_buffer This is an arrayreference containing all the output sent to STDERR the -command generated. -Note that buffers are only available if you have C<IPC::Run> installed, -or if your system is able to work with C<IPC::Open3> -- See below). -This element will be C<undef> if this is not the case. +command generated. The notes from L<"full_buffer"> apply. + =back -See the C<HOW IT WORKS> Section below to see how C<IPC::Cmd> decides +See the L<"HOW IT WORKS"> section below to see how C<IPC::Cmd> decides what modules or function calls to use when issuing a command. =cut @@ -596,8 +590,8 @@ sub open3_run { C<run_forked> is used to execute some program or a coderef, optionally feed it with some input, get its return code and output (both stdout and stderr into separate buffers). -In addition it allows to terminate the program -which take too long to finish. +In addition, it allows to terminate the program +if it takes too long to finish. The important and distinguishing feature of run_forked is execution timeout which at first seems to be @@ -625,22 +619,23 @@ Invocation requires the command to be executed or a coderef and optionally a has =item C<timeout> -Specify in seconds how long the command may run for before it is killed with with SIG_KILL (9) +Specify in seconds how long to run the command before it is killed with with SIG_KILL (9), which effectively terminates it and all of its children (direct or indirect). =item C<child_stdin> -Specify some text that will be passed into C<STDIN> of the executed program. +Specify some text that will be passed into the C<STDIN> of the executed program. =item C<stdout_handler> -You may provide a coderef of a subroutine that will be called a portion of data is received on -stdout from the executing program. +Coderef of a subroutine to call when a portion of data is received on +STDOUT from the executing program. =item C<stderr_handler> -You may provide a coderef of a subroutine that will be called a portion of data is received on -stderr from the executing program. +Coderef of a subroutine to call when a portion of data is received on +STDERR from the executing program. + =item C<discard_output> @@ -669,18 +664,18 @@ The number of seconds the program ran for before being terminated, or 0 if no ti =item C<stdout> -Holds the standard output of the executed command -(or empty string if there were no stdout output or if discard_output was used; it's always defined!) +Holds the standard output of the executed command (or empty string if +there was no STDOUT output or if C<discard_output> was used; it's always defined!) =item C<stderr> -Holds the standard error of the executed command -(or empty string if there were no stderr output or if discard_output was used; it's always defined!) +Holds the standard error of the executed command (or empty string if +there was no STDERR output or if C<discard_output> was used; it's always defined!) =item C<merged> Holds the standard output and error of the executed command merged into one stream -(or empty string if there were no output at all or if discard_output was used; it's always defined!) +(or empty string if there was no output at all or if C<discard_output> was used; it's always defined!) =item C<err_msg> @@ -1256,7 +1251,7 @@ sub _open3_run { } } -### text::parsewords::shellwordss() uses unix semantics. that will break +### Text::ParseWords::shellwords() uses unix semantics. that will break ### on win32 { my $parse_sub = IS_WIN32 ? __PACKAGE__->can('_split_like_shell_win32') @@ -1504,7 +1499,7 @@ sub _split_like_shell_win32 { } elsif ( $ch eq '"' ) { $quote_mode = !$quote_mode; } elsif ( $ch eq ' ' && !$quote_mode ) { - push( @argv, $arg ) if $arg; + push( @argv, $arg ) if defined( $arg ) && length( $arg ); $arg = ''; ++$i while substr( $_, $i + 1, 1 ) eq ' '; } else { @@ -1657,28 +1652,28 @@ C<run> will try to execute your command using the following logic: =item * If you have C<IPC::Run> installed, and the variable C<$IPC::Cmd::USE_IPC_RUN> -is set to true (See the C<GLOBAL VARIABLES> Section) use that to execute +is set to true (See the L<"Global Variables"> section) use that to execute the command. You will have the full output available in buffers, interactive commands are sure to work and you are guaranteed to have your verbosity settings honored cleanly. =item * Otherwise, if the variable C<$IPC::Cmd::USE_IPC_OPEN3> is set to true -(See the C<GLOBAL VARIABLES> Section), try to execute the command using -C<IPC::Open3>. Buffers will be available on all platforms except C<Win32>, +(See the L<"Global Variables"> section), try to execute the command using +L<IPC::Open3>. Buffers will be available on all platforms except C<Win32>, interactive commands will still execute cleanly, and also your verbosity settings will be adhered to nicely; =item * -Otherwise, if you have the verbose argument set to true, we fall back -to a simple system() call. We cannot capture any buffers, but +Otherwise, if you have the C<verbose> argument set to true, we fall back +to a simple C<system()> call. We cannot capture any buffers, but interactive commands will still work. =item * Otherwise we will try and temporarily redirect STDERR and STDOUT, do a -system() call with your command and then re-open STDERR and STDOUT. +C<system()> call with your command and then re-open STDERR and STDOUT. This is the method of last resort and will still allow you to execute your commands cleanly. However, no buffers will be available. @@ -1692,7 +1687,7 @@ global variables: =head2 $IPC::Cmd::VERBOSE This controls whether IPC::Cmd will print any output from the -commands to the screen or not. The default is 0; +commands to the screen or not. The default is 0. =head2 $IPC::Cmd::USE_IPC_RUN @@ -1706,7 +1701,7 @@ when available and suitable. Defaults to true. =head2 $IPC::Cmd::WARN -This variable controls whether run time warnings should be issued, like +This variable controls whether run-time warnings should be issued, like the failure to load an C<IPC::*> module you explicitly requested. Defaults to true. Turn this off at your own risk. @@ -1727,16 +1722,16 @@ Defaults to false, set to true to enable the described behaviour. When using C<IPC::Open3> or C<system>, if you provide a string as the C<command> argument, it is assumed to be appropriately escaped. You can use the C<QUOTE> constant to use as a portable quote character (see above). -However, if you provide and C<Array Reference>, special rules apply: +However, if you provide an array reference, special rules apply: -If your command contains C<Special Characters> (< > | &), it will +If your command contains B<special characters> (< > | &), it will be internally stringified before executing the command, to avoid that these special characters are escaped and passed as arguments instead of retaining their special meaning. However, if the command contained arguments that contained whitespace, stringifying the command would loose the significance of the whitespace. -Therefor, C<IPC::Cmd> will quote any arguments containing whitespace in your +Therefore, C<IPC::Cmd> will quote any arguments containing whitespace in your command if the command is passed as an arrayref and contains special characters. =item Whitespace and IPC::Run @@ -1748,7 +1743,7 @@ break if you have files or commands with whitespace in them. If you do not wish this to happen, you should provide an array reference, where all parts of your command are already separated out. -Note however, if there's extra or spurious whitespace in these parts, +Note however, if there are extra or spurious whitespaces in these parts, the parser or underlying code may not interpret it correctly, and cause an error. @@ -1775,36 +1770,39 @@ Since this will lead to issues as described above. =item IO Redirect Currently it is too complicated to parse your command for IO -Redirections. For capturing STDOUT or STDERR there is a work around +redirections. For capturing STDOUT or STDERR there is a work around however, since you can just inspect your buffers for the contents. =item Interleaving STDOUT/STDERR Neither IPC::Run nor IPC::Open3 can interleave STDOUT and STDERR. For short -bursts of output from a program, ie this sample: +bursts of output from a program, e.g. this sample, for ( 1..4 ) { $_ % 2 ? print STDOUT $_ : print STDERR $_; } IPC::[Run|Open3] will first read all of STDOUT, then all of STDERR, meaning -the output looks like 1 line on each, namely '13' on STDOUT and '24' on STDERR. +the output looks like '13' on STDOUT and '24' on STDERR, instead of -It should have been 1, 2, 3, 4. + 1 + 2 + 3 + 4 This has been recorded in L<rt.cpan.org> as bug #37532: Unable to interleave -STDOUT and STDERR +STDOUT and STDERR. =back =head1 See Also -C<IPC::Run>, C<IPC::Open3> +L<IPC::Run>, L<IPC::Open3> =head1 ACKNOWLEDGEMENTS Thanks to James Mastros and Martijn van der Streek for their -help in getting IPC::Open3 to behave nicely. +help in getting L<IPC::Open3> to behave nicely. Thanks to Petya Kohts for the C<run_forked> code. @@ -1814,7 +1812,8 @@ Please report bugs or other issues to E<lt>bug-ipc-cmd@rt.cpan.orgE<gt>. =head1 AUTHOR -This module by Jos Boumans E<lt>kane@cpan.orgE<gt>. +Original author: Jos Boumans E<lt>kane@cpan.orgE<gt>. +Current maintainer: Chris Williams E<lt>bingos@cpan.orgE<gt>. =head1 COPYRIGHT |