diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1999-06-10 00:05:22 -0400 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-06 20:10:50 +0000 |
commit | 603a98b057dc0594e88193eb408d3eea3f3e4908 (patch) | |
tree | 5ef22db63b14bbadd66e6db7c601322810dd3c72 /doio.c | |
parent | ca5b42cb45f4f349d2f4294782df89816ca80d76 (diff) | |
download | perl-603a98b057dc0594e88193eb408d3eea3f3e4908.tar.gz |
Optimize 2>&1 in commands
Message-Id: <199906100805.EAA18216@monk.mps.ohio-state.edu>
p4raw-id: //depot/perl@3621
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1126,6 +1126,20 @@ Perl_do_exec3(pTHX_ char *cmd, int fd, int do_report) *s = '\0'; break; } + /* handle the 2>&1 construct at the end */ + if (*s == '>' && s[1] == '&' && s[2] == '1' + && s > cmd + 1 && s[-1] == '2' && isSPACE(s[-2]) + && (!s[3] || isSPACE(s[3]))) + { + char *t = s + 3; + + while (*t && isSPACE(*t)) + ++t; + if (!*t && (dup2(1,2) != -1)) { + s[-2] = '\0'; + break; + } + } doshell: PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char*)0); return FALSE; |