summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_sys.c3
-rwxr-xr-xt/op/exec.t8
2 files changed, 10 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 0183325cb9..c55f0a4651 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -321,10 +321,13 @@ PP(pp_backtick)
;
}
else if (gimme == G_SCALAR) {
+ SV *oldrs = PL_rs;
+ PL_rs = &PL_sv_undef;
sv_setpv(TARG, ""); /* note that this preserves previous buffer */
while (sv_gets(TARG, fp, SvCUR(TARG)) != Nullch)
/*SUPPRESS 530*/
;
+ PL_rs = oldrs;
XPUSHs(TARG);
SvTAINTED_on(TARG);
}
diff --git a/t/op/exec.t b/t/op/exec.t
index 3edbc6ac62..5f110be32e 100755
--- a/t/op/exec.t
+++ b/t/op/exec.t
@@ -19,7 +19,7 @@ my $Is_Win32 = $^O eq 'MSWin32';
skip_all("Tests mostly usesless on MacOS") if $^O eq 'MacOS';
-plan(tests => 20);
+plan(tests => 21);
my $Perl = which_perl();
@@ -74,6 +74,12 @@ is( $echo_out, "ok\n", 'piped echo emulation');
is( scalar `$Perl -le "print 'ok'" | $Perl -e "print <STDIN>"`,
"ok\n", 'extra newlines on outgoing pipes');
+
+ {
+ local($/) = \2;
+ $out = runperl(prog => 'print q{1234}');
+ is($out, "1234", 'ignore $/ when capturing output in scalar context');
+ }
}