summaryrefslogtreecommitdiffstats
path: root/upstream/archlinux/man3/IPC::Cmd.3perl
blob: 8123a2feb44384d0d44287277e5bb983da364f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "IPC::Cmd 3perl"
.TH IPC::Cmd 3perl 2024-02-11 "perl v5.38.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
IPC::Cmd \- finding and running system commands made easy
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\&    use IPC::Cmd qw[can_run run run_forked];
\&
\&    my $full_path = can_run(\*(Aqwget\*(Aq) or warn \*(Aqwget is not installed!\*(Aq;
\&
\&    ### commands can be arrayrefs or strings ###
\&    my $cmd = "$full_path \-b theregister.co.uk";
\&    my $cmd = [$full_path, \*(Aq\-b\*(Aq, \*(Aqtheregister.co.uk\*(Aq];
\&
\&    ### in scalar context ###
\&    my $buffer;
\&    if( scalar run( command => $cmd,
\&                    verbose => 0,
\&                    buffer  => \e$buffer,
\&                    timeout => 20 )
\&    ) {
\&        print "fetched webpage successfully: $buffer\en";
\&    }
\&
\&
\&    ### in list context ###
\&    my( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) =
\&            run( command => $cmd, verbose => 0 );
\&
\&    if( $success ) {
\&        print "this is what the command printed:\en";
\&        print join "", @$full_buf;
\&    }
\&
\&    ### run_forked example ###
\&    my $result = run_forked("$full_path \-q \-O \- theregister.co.uk", {\*(Aqtimeout\*(Aq => 20});
\&    if ($result\->{\*(Aqexit_code\*(Aq} eq 0 && !$result\->{\*(Aqtimeout\*(Aq}) {
\&        print "this is what wget returned:\en";
\&        print $result\->{\*(Aqstdout\*(Aq};
\&    }
\&
\&    ### check for features
\&    print "IPC::Open3 available: "  . IPC::Cmd\->can_use_ipc_open3;
\&    print "IPC::Run available: "    . IPC::Cmd\->can_use_ipc_run;
\&    print "Can capture buffer: "    . IPC::Cmd\->can_capture_buffer;
\&
\&    ### don\*(Aqt have IPC::Cmd be verbose, ie don\*(Aqt print to stdout or
\&    ### stderr when running commands \-\- default is \*(Aq0\*(Aq
\&    $IPC::Cmd::VERBOSE = 0;
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
IPC::Cmd allows you to run commands platform independently,
interactively if desired, but have them still work.
.PP
The \f(CW\*(C`can_run\*(C'\fR function can tell you if a certain binary is installed
and if so where, whereas the \f(CW\*(C`run\*(C'\fR function can actually execute any
of the commands you give it and give you a clear return value, as well
as adhere to your verbosity settings.
.SH "CLASS METHODS"
.IX Header "CLASS METHODS"
.ie n .SS "$ipc_run_version = IPC::Cmd\->can_use_ipc_run( [VERBOSE] )"
.el .SS "\f(CW$ipc_run_version\fP = IPC::Cmd\->can_use_ipc_run( [VERBOSE] )"
.IX Subsection "$ipc_run_version = IPC::Cmd->can_use_ipc_run( [VERBOSE] )"
Utility function that tells you if \f(CW\*(C`IPC::Run\*(C'\fR is available.
If the \f(CW\*(C`verbose\*(C'\fR flag is passed, it will print diagnostic messages
if IPC::Run can not be found or loaded.
.ie n .SS "$ipc_open3_version = IPC::Cmd\->can_use_ipc_open3( [VERBOSE] )"
.el .SS "\f(CW$ipc_open3_version\fP = IPC::Cmd\->can_use_ipc_open3( [VERBOSE] )"
.IX Subsection "$ipc_open3_version = IPC::Cmd->can_use_ipc_open3( [VERBOSE] )"
Utility function that tells you if \f(CW\*(C`IPC::Open3\*(C'\fR is available.
If the verbose flag is passed, it will print diagnostic messages
if \f(CW\*(C`IPC::Open3\*(C'\fR can not be found or loaded.
.ie n .SS "$bool = IPC::Cmd\->can_capture_buffer"
.el .SS "\f(CW$bool\fP = IPC::Cmd\->can_capture_buffer"
.IX Subsection "$bool = IPC::Cmd->can_capture_buffer"
Utility function that tells you if \f(CW\*(C`IPC::Cmd\*(C'\fR is capable of
capturing buffers in it's current configuration.
.ie n .SS "$bool = IPC::Cmd\->can_use_run_forked"
.el .SS "\f(CW$bool\fP = IPC::Cmd\->can_use_run_forked"
.IX Subsection "$bool = IPC::Cmd->can_use_run_forked"
Utility function that tells you if \f(CW\*(C`IPC::Cmd\*(C'\fR is capable of
providing \f(CW\*(C`run_forked\*(C'\fR on the current platform.
.SH FUNCTIONS
.IX Header "FUNCTIONS"
.ie n .SS "$path = can_run( PROGRAM );"
.el .SS "\f(CW$path\fP = can_run( PROGRAM );"
.IX Subsection "$path = can_run( PROGRAM );"
\&\f(CW\*(C`can_run\*(C'\fR takes only one argument: the name of a binary you wish
to locate. \f(CW\*(C`can_run\*(C'\fR works much like the unix binary \f(CW\*(C`which\*(C'\fR or the bash
command \f(CW\*(C`type\*(C'\fR, which scans through your path, looking for the requested
binary.
.PP
Unlike \f(CW\*(C`which\*(C'\fR and \f(CW\*(C`type\*(C'\fR, this function is platform independent and
will also work on, for example, Win32.
.PP
If called in a scalar context it will return the full path to the binary
you asked for if it was found, or \f(CW\*(C`undef\*(C'\fR if it was not.
.PP
If called in a list context and the global variable \f(CW$INSTANCES\fR is a true
value, it will return a list of the full paths to instances
of the binary where found in \f(CW\*(C`PATH\*(C'\fR, or an empty list if it was not found.
.ie n .SS "$ok | ($ok, $err, $full_buf, $stdout_buff, $stderr_buff) = run( command => COMMAND, [verbose => BOOL, buffer => \e$SCALAR, timeout => DIGIT] );"
.el .SS "\f(CW$ok\fP | ($ok, \f(CW$err\fP, \f(CW$full_buf\fP, \f(CW$stdout_buff\fP, \f(CW$stderr_buff\fP) = run( command => COMMAND, [verbose => BOOL, buffer => \e$SCALAR, timeout => DIGIT] );"
.IX Subsection "$ok | ($ok, $err, $full_buf, $stdout_buff, $stderr_buff) = run( command => COMMAND, [verbose => BOOL, buffer => $SCALAR, timeout => DIGIT] );"
\&\f(CW\*(C`run\*(C'\fR takes 4 arguments:
.IP command 4
.IX Item "command"
This is the command to execute. It may be either a string or an array
reference.
This is a required argument.
.Sp
See "Caveats" for remarks on how commands are parsed and their
limitations.
.IP verbose 4
.IX 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 IPC::Run to be installed, or your system able to work with
IPC::Open3).
.Sp
It will default to the global setting of \f(CW$IPC::Cmd::VERBOSE\fR,
which by default is 0.
.IP buffer 4
.IX Item "buffer"
This will hold all the output of a command. It needs to be a reference
to a scalar.
Note that this will hold both the STDOUT and STDERR messages, and you
have no way of telling which is which.
If you require this distinction, run the \f(CW\*(C`run\*(C'\fR command in list context
and inspect the individual buffers.
.Sp
Of course, this requires that the underlying call supports buffers. See
the note on buffers above.
.IP timeout 4
.IX Item "timeout"
Sets the maximum time the command is allowed to run before aborting,
using the built-in \f(CWalarm()\fR call. If the timeout is triggered, the
\&\f(CW\*(C`errorcode\*(C'\fR in the return value will be set to an object of the
\&\f(CW\*(C`IPC::Cmd::TimeOut\*(C'\fR class. See the "error message" section below for
details.
.Sp
Defaults to \f(CW0\fR, meaning no timeout is set.
.PP
\&\f(CW\*(C`run\*(C'\fR will return a simple \f(CW\*(C`true\*(C'\fR or \f(CW\*(C`false\*(C'\fR when called in scalar
context.
In list context, you will be returned a list of the following items:
.IP success 4
.IX Item "success"
A simple boolean indicating if the command executed without errors or
not.
.IP "error message" 4
.IX Item "error message"
If the first element of the return value (\f(CW\*(C`success\*(C'\fR) 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 \f(CW$?\fR or \f(CW$@\fR. See \f(CW\*(C`perldoc perlvar\*(C'\fR for details on
what they can contain.
If the error was a timeout, the \f(CW\*(C`error message\*(C'\fR will be prefixed with
the string \f(CW\*(C`IPC::Cmd::TimeOut\*(C'\fR, the timeout class.
.IP full_buffer 4
.IX Item "full_buffer"
This is an array reference containing all the output the command
generated.
Note that buffers are only available if you have IPC::Run installed,
or if your system is able to work with IPC::Open3 \-\- see below).
Otherwise, this element will be \f(CW\*(C`undef\*(C'\fR.
.IP out_buffer 4
.IX Item "out_buffer"
This is an array reference containing all the output sent to STDOUT the
command generated. The notes from "full_buffer" apply.
.IP error_buffer 4
.IX Item "error_buffer"
This is an arrayreference containing all the output sent to STDERR the
command generated. The notes from "full_buffer" apply.
.PP
See the "HOW IT WORKS" section below to see how \f(CW\*(C`IPC::Cmd\*(C'\fR decides
what modules or function calls to use when issuing a command.
.ie n .SS "$hashref = run_forked( COMMAND, { child_stdin => SCALAR, timeout => DIGIT, stdout_handler => CODEREF, stderr_handler => CODEREF} );"
.el .SS "\f(CW$hashref\fP = run_forked( COMMAND, { child_stdin => SCALAR, timeout => DIGIT, stdout_handler => CODEREF, stderr_handler => CODEREF} );"
.IX Subsection "$hashref = run_forked( COMMAND, { child_stdin => SCALAR, timeout => DIGIT, stdout_handler => CODEREF, stderr_handler => CODEREF} );"
\&\f(CW\*(C`run_forked\*(C'\fR 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
if it takes too long to finish.
.PP
The important and distinguishing feature of run_forked
is execution timeout which at first seems to be
quite a simple task but if you think
that the program which you're spawning
might spawn some children itself (which
in their turn could do the same and so on)
it turns out to be not a simple issue.
.PP
\&\f(CW\*(C`run_forked\*(C'\fR is designed to survive and
successfully terminate almost any long running task,
even a fork bomb in case your system has the resources
to survive during given timeout.
.PP
This is achieved by creating separate watchdog process
which spawns the specified program in a separate
process session and supervises it: optionally
feeds it with input, stores its exit code,
stdout and stderr, terminates it in case
it runs longer than specified.
.PP
Invocation requires the command to be executed or a coderef and optionally a hashref of options:
.ie n .IP """timeout""" 4
.el .IP \f(CWtimeout\fR 4
.IX Item "timeout"
Specify in seconds how long to run the command before it is killed with SIG_KILL (9),
which effectively terminates it and all of its children (direct or indirect).
.ie n .IP """child_stdin""" 4
.el .IP \f(CWchild_stdin\fR 4
.IX Item "child_stdin"
Specify some text that will be passed into the \f(CW\*(C`STDIN\*(C'\fR of the executed program.
.ie n .IP """stdout_handler""" 4
.el .IP \f(CWstdout_handler\fR 4
.IX Item "stdout_handler"
Coderef of a subroutine to call when a portion of data is received on
STDOUT from the executing program.
.ie n .IP """stderr_handler""" 4
.el .IP \f(CWstderr_handler\fR 4
.IX Item "stderr_handler"
Coderef of a subroutine to call when a portion of data is received on
STDERR from the executing program.
.ie n .IP """wait_loop_callback""" 4
.el .IP \f(CWwait_loop_callback\fR 4
.IX Item "wait_loop_callback"
Coderef of a subroutine to call inside of the main waiting loop
(while \f(CW\*(C`run_forked\*(C'\fR waits for the external to finish or fail).
It is useful to stop running external process before it ends
by itself, e.g.
.Sp
.Vb 8
\&  my $r = run_forked("some external command", {
\&          \*(Aqwait_loop_callback\*(Aq => sub {
\&          if (condition) {
\&              kill(1, $$);
\&          }
\&          },
\&          \*(Aqterminate_on_signal\*(Aq => \*(AqHUP\*(Aq,
\&          });
.Ve
.Sp
Combined with \f(CW\*(C`stdout_handler\*(C'\fR and \f(CW\*(C`stderr_handler\*(C'\fR allows terminating
external command based on its output. Could also be used as a timer
without engaging with alarm (signals).
.Sp
Remember that this code could be called every millisecond (depending
on the output which external command generates), so try to make it
as lightweight as possible.
.ie n .IP """discard_output""" 4
.el .IP \f(CWdiscard_output\fR 4
.IX Item "discard_output"
Discards the buffering of the standard output and standard errors for return by \fBrun_forked()\fR.
With this option you have to use the std*_handlers to read what the command outputs.
Useful for commands that send a lot of output.
.ie n .IP """terminate_on_parent_sudden_death""" 4
.el .IP \f(CWterminate_on_parent_sudden_death\fR 4
.IX Item "terminate_on_parent_sudden_death"
Enable this option if you wish all spawned processes to be killed if the initially spawned
process (the parent) is killed or dies without waiting for child processes.
.PP
\&\f(CW\*(C`run_forked\*(C'\fR will return a HASHREF with the following keys:
.ie n .IP """exit_code""" 4
.el .IP \f(CWexit_code\fR 4
.IX Item "exit_code"
The exit code of the executed program.
.ie n .IP """timeout""" 4
.el .IP \f(CWtimeout\fR 4
.IX Item "timeout"
The number of seconds the program ran for before being terminated, or 0 if no timeout occurred.
.ie n .IP """stdout""" 4
.el .IP \f(CWstdout\fR 4
.IX Item "stdout"
Holds the standard output of the executed command (or empty string if
there was no STDOUT output or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """stderr""" 4
.el .IP \f(CWstderr\fR 4
.IX Item "stderr"
Holds the standard error of the executed command (or empty string if
there was no STDERR output or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """merged""" 4
.el .IP \f(CWmerged\fR 4
.IX Item "merged"
Holds the standard output and error of the executed command merged into one stream
(or empty string if there was no output at all or if \f(CW\*(C`discard_output\*(C'\fR was used; it's always defined!)
.ie n .IP """err_msg""" 4
.el .IP \f(CWerr_msg\fR 4
.IX Item "err_msg"
Holds some explanation in the case of an error.
.ie n .SS "$q = QUOTE"
.el .SS "\f(CW$q\fP = QUOTE"
.IX Subsection "$q = QUOTE"
Returns the character used for quoting strings on this platform. This is
usually a \f(CW\*(C`\*(Aq\*(C'\fR (single quote) on most systems, but some systems use different
quotes. For example, \f(CW\*(C`Win32\*(C'\fR uses \f(CW\*(C`"\*(C'\fR (double quote).
.PP
You can use it as follows:
.PP
.Vb 2
\&  use IPC::Cmd qw[run QUOTE];
\&  my $cmd = q[echo ] . QUOTE . q[foo bar] . QUOTE;
.Ve
.PP
This makes sure that \f(CW\*(C`foo bar\*(C'\fR is treated as a string, rather than two
separate arguments to the \f(CW\*(C`echo\*(C'\fR function.
.SH "HOW IT WORKS"
.IX Header "HOW IT WORKS"
\&\f(CW\*(C`run\*(C'\fR will try to execute your command using the following logic:
.IP \(bu 4
If you have \f(CW\*(C`IPC::Run\*(C'\fR installed, and the variable \f(CW$IPC::Cmd::USE_IPC_RUN\fR
is set to true (See the "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.
.IP \(bu 4
Otherwise, if the variable \f(CW$IPC::Cmd::USE_IPC_OPEN3\fR is set to true
(See the "Global Variables" section), try to execute the command using
IPC::Open3. Buffers will be available on all platforms,
interactive commands will still execute cleanly, and also your verbosity
settings will be adhered to nicely;
.IP \(bu 4
Otherwise, if you have the \f(CW\*(C`verbose\*(C'\fR argument set to true, we fall back
to a simple \f(CWsystem()\fR call. We cannot capture any buffers, but
interactive commands will still work.
.IP \(bu 4
Otherwise we will try and temporarily redirect STDERR and STDOUT, do a
\&\f(CWsystem()\fR 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.
.SH "Global Variables"
.IX Header "Global Variables"
The behaviour of IPC::Cmd can be altered by changing the following
global variables:
.ie n .SS $IPC::Cmd::VERBOSE
.el .SS \f(CW$IPC::Cmd::VERBOSE\fP
.IX Subsection "$IPC::Cmd::VERBOSE"
This controls whether IPC::Cmd will print any output from the
commands to the screen or not. The default is 0.
.ie n .SS $IPC::Cmd::USE_IPC_RUN
.el .SS \f(CW$IPC::Cmd::USE_IPC_RUN\fP
.IX Subsection "$IPC::Cmd::USE_IPC_RUN"
This variable controls whether IPC::Cmd will try to use IPC::Run
when available and suitable.
.ie n .SS $IPC::Cmd::USE_IPC_OPEN3
.el .SS \f(CW$IPC::Cmd::USE_IPC_OPEN3\fP
.IX Subsection "$IPC::Cmd::USE_IPC_OPEN3"
This variable controls whether IPC::Cmd will try to use IPC::Open3
when available and suitable. Defaults to true.
.ie n .SS $IPC::Cmd::WARN
.el .SS \f(CW$IPC::Cmd::WARN\fP
.IX Subsection "$IPC::Cmd::WARN"
This variable controls whether run-time warnings should be issued, like
the failure to load an \f(CW\*(C`IPC::*\*(C'\fR module you explicitly requested.
.PP
Defaults to true. Turn this off at your own risk.
.ie n .SS $IPC::Cmd::INSTANCES
.el .SS \f(CW$IPC::Cmd::INSTANCES\fP
.IX Subsection "$IPC::Cmd::INSTANCES"
This variable controls whether \f(CW\*(C`can_run\*(C'\fR will return all instances of
the binary it finds in the \f(CW\*(C`PATH\*(C'\fR when called in a list context.
.PP
Defaults to false, set to true to enable the described behaviour.
.ie n .SS $IPC::Cmd::ALLOW_NULL_ARGS
.el .SS \f(CW$IPC::Cmd::ALLOW_NULL_ARGS\fP
.IX Subsection "$IPC::Cmd::ALLOW_NULL_ARGS"
This variable controls whether \f(CW\*(C`run\*(C'\fR will remove any empty/null arguments
it finds in command arguments.
.PP
Defaults to false, so it will remove null arguments. Set to true to allow
them.
.SH Caveats
.IX Header "Caveats"
.IP "Whitespace and IPC::Open3 / \fBsystem()\fR" 4
.IX Item "Whitespace and IPC::Open3 / system()"
When using \f(CW\*(C`IPC::Open3\*(C'\fR or \f(CW\*(C`system\*(C'\fR, if you provide a string as the
\&\f(CW\*(C`command\*(C'\fR argument, it is assumed to be appropriately escaped. You can
use the \f(CW\*(C`QUOTE\*(C'\fR constant to use as a portable quote character (see above).
However, if you provide an array reference, special rules apply:
.Sp
If your command contains \fBspecial characters\fR (< > | &), 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.
.Sp
However, if the command contained arguments that contained whitespace,
stringifying the command would lose the significance of the whitespace.
Therefore, \f(CW\*(C`IPC::Cmd\*(C'\fR will quote any arguments containing whitespace in your
command if the command is passed as an arrayref and contains special characters.
.IP "Whitespace and IPC::Run" 4
.IX Item "Whitespace and IPC::Run"
When using \f(CW\*(C`IPC::Run\*(C'\fR, if you provide a string as the \f(CW\*(C`command\*(C'\fR argument,
the string will be split on whitespace to determine the individual elements
of your command. Although this will usually just Do What You Mean, it may
break if you have files or commands with whitespace in them.
.Sp
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 are extra or spurious whitespaces in these parts,
the parser or underlying code may not interpret it correctly, and
cause an error.
.Sp
Example:
The following code
.Sp
.Vb 1
\&    gzip \-cdf foo.tar.gz | tar \-xf \-
.Ve
.Sp
should either be passed as
.Sp
.Vb 1
\&    "gzip \-cdf foo.tar.gz | tar \-xf \-"
.Ve
.Sp
or as
.Sp
.Vb 1
\&    [\*(Aqgzip\*(Aq, \*(Aq\-cdf\*(Aq, \*(Aqfoo.tar.gz\*(Aq, \*(Aq|\*(Aq, \*(Aqtar\*(Aq, \*(Aq\-xf\*(Aq, \*(Aq\-\*(Aq]
.Ve
.Sp
But take care not to pass it as, for example
.Sp
.Vb 1
\&    [\*(Aqgzip \-cdf foo.tar.gz\*(Aq, \*(Aq|\*(Aq, \*(Aqtar \-xf \-\*(Aq]
.Ve
.Sp
Since this will lead to issues as described above.
.IP "IO Redirect" 4
.IX 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
however, since you can just inspect your buffers for the contents.
.IP "Interleaving STDOUT/STDERR" 4
.IX Item "Interleaving STDOUT/STDERR"
Neither IPC::Run nor IPC::Open3 can interleave STDOUT and STDERR. For short
bursts of output from a program, e.g. this sample,
.Sp
.Vb 3
\&    for ( 1..4 ) {
\&        $_ % 2 ? print STDOUT $_ : print STDERR $_;
\&    }
.Ve
.Sp
IPC::[Run|Open3] will first read all of STDOUT, then all of STDERR, meaning
the output looks like '13' on STDOUT and '24' on STDERR, instead of
.Sp
.Vb 4
\&    1
\&    2
\&    3
\&    4
.Ve
.Sp
This has been recorded in rt.cpan.org as bug #37532: Unable to interleave
STDOUT and STDERR.
.SH "See Also"
.IX Header "See Also"
IPC::Run, IPC::Open3
.SH ACKNOWLEDGEMENTS
.IX Header "ACKNOWLEDGEMENTS"
Thanks to James Mastros and Martijn van der Streek for their
help in getting IPC::Open3 to behave nicely.
.PP
Thanks to Petya Kohts for the \f(CW\*(C`run_forked\*(C'\fR code.
.SH "BUG REPORTS"
.IX Header "BUG REPORTS"
Please report bugs or other issues to <bug\-ipc\-cmd@rt.cpan.org>.
.SH AUTHOR
.IX Header "AUTHOR"
Original author: Jos Boumans <kane@cpan.org>.
Current maintainer: Chris Williams <bingos@cpan.org>.
.SH COPYRIGHT
.IX Header "COPYRIGHT"
This library is free software; you may redistribute and/or modify it
under the same terms as Perl itself.