in reply to Re: capturing command output
in thread capturing command output
what other part should take care of the redirection 2>&1?
Perl itself? Like it does on Unix when 2>&1 is the only shell meta characters in the command.*
I don't think Perl is making this optimisation on Windows, though, but I do think it's a valid question — considering that in Perl things are not always quite as obvious as it might seem at first...
___
* as you can easily verify:
$ strace -fqeexecve perl -e 'open FH, "echo foo bar 2>&1 |"; print <FH +>' execve("/usr/bin/perl", ["perl", "-e", "open FH, \"echo foo bar 2>&1 | +\"; "...], [/* 77 vars */]) = 0 [pid 1819] execve("/bin/echo", ["echo", "foo", "bar"], [/* 77 vars */ +]) = 0 foo bar
No shell involved here. But as soon as you add another shell metacharacter, e.g. ";", Perl will use the shell:
$ strace -fqeexecve perl -e 'open FH, "echo foo bar ; 2>&1 |"; print < +FH>' execve("/usr/bin/perl", ["perl", "-e", "open FH, \"echo foo bar ; 2>&1 + |\""...], [/* 77 vars */]) = 0 [pid 1833] execve("/bin/sh", ["sh", "-c", "echo foo bar ; 2>&1"], [/* + 77 vars */]) = 0 foo bar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: capturing command output
by chrestomanci (Priest) on Jan 25, 2012 at 13:56 UTC | |
by Eliya (Vicar) on Jan 25, 2012 at 14:17 UTC |