3 our($capture_stderr $VERSION);
9 my ($callpack, $callfile, $callline) = caller;
17 foreach $sym (@EXPORT) {
18 *{"${callpack}::$sym"} = \&{"Shell::$sym"};
28 \$Shell::capture_stderr ? `$cmd 2>&1` : `$cmd`;
30 elsif ('$^O' eq 'os2') {
31 local(\*SAVEOUT, \*READ, \*WRITE);
33 open SAVEOUT, '>&STDOUT' or die;
34 pipe READ, WRITE or die;
35 open STDOUT, '>&WRITE' or die;
38 my \$pid = system(1, '$cmd', \@_);
39 die "Can't execute $cmd: \$!\\n" if \$pid < 0;
41 open STDOUT, '>&SAVEOUT' or die;
61 if ('$^O' eq 'MSWin32') {
62 # XXX this special-casing should not be needed
63 # if we do quoting right on Windows. :-(
65 # First, escape all quotes. Cover the case where we
66 # want to pass along a quote preceded by a backslash
67 # (i.e., C<"param \\""" end">).
68 # Ugly, yup? You know, windoze.
69 # Enclose in quotes only the parameters that need it:
70 # try this: c:\> dir "/w"
71 # and this: c:\> dir /w
74 s/\\\\\\\\"/\\\\\\\\"""/g;
75 \$_ = qq["\$_"] if /\s/;
80 s/(['\\\\])/\\\\\$1/g;
84 push \@arr, '2>&1' if \$Shell::capture_stderr;
85 open(SUBPROC, join(' ', '$cmd', \@arr, '|'))
86 or die "Can't exec $cmd: \$!\\n";
89 close SUBPROC; # XXX Oughta use a destructor.
111 Shell - run shell commands transparently within perl
119 Date: Thu, 22 Sep 94 16:18:16 -0700
120 Message-Id: <9409222318.AA17072@scalpel.netlabs.com>
121 To: perl5-porters@isu.edu
122 From: Larry Wall <lwall@scalpel.netlabs.com>
123 Subject: a new module I just wrote
125 Here's one that'll whack your mind a little out.
131 $foo = echo("howdy", "<funny>", "world");
134 $passwd = cat("</etc/passwd");
140 cp("/etc/passwd", "/tmp/passwd");
142 That's maybe too gonzo. It actually exports an AUTOLOAD to the current
143 package (and uncovered a bug in Beta 3, by the way). Maybe the usual
146 use Shell qw(echo cat ps cp);
151 If you set $Shell::capture_stderr to 1, the module will attempt to
152 capture the STDERR of the process as well.
154 The module now should work on Win32.
162 Changes by Jenda@Krynicky.cz and Dave Cottle <d.cottle@csc.canterbury.ac.nz>