summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgs@consttype.org>2014-07-24 17:43:29 +0200
committerRafael Garcia-Suarez <rgs@consttype.org>2014-09-30 08:17:50 +0200
commit157fb5a14d10ed16ffc6ebfc43d2637a016fdfce (patch)
treeb2410287e269d41f3295678586e62ce4fa459188 /doio.c
parentf276fdad8f6660f36944c895587a7748585e4969 (diff)
downloadperl-157fb5a14d10ed16ffc6ebfc43d2637a016fdfce.tar.gz
Introduce the double-diamond operator <<>>
This operator works like <> or <ARGV>, as it reads the list of file names to open from the command-line arguments. However, it disables the magic-open feature (that forks to execute piped commands) : $ bleadperl -e 'while(<>){print}' 'echo foo |' foo $ bleadperl -e 'while(<<>>){print}' 'echo foo |' Can't open echo foo |: No such file or directory at -e line 1.
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/doio.c b/doio.c
index a631eeb038..c7aceca641 100644
--- a/doio.c
+++ b/doio.c
@@ -799,7 +799,7 @@ say_false:
}
PerlIO *
-Perl_nextargv(pTHX_ GV *gv)
+Perl_nextargv(pTHX_ GV *gv, bool nomagicopen)
{
IO * const io = GvIOp(gv);
@@ -837,7 +837,10 @@ Perl_nextargv(pTHX_ GV *gv)
SvSETMAGIC(GvSV(gv));
PL_oldname = SvPVx(GvSV(gv), oldlen);
if (LIKELY(!PL_inplace)) {
- if (do_open6(gv, PL_oldname, oldlen, NULL, NULL, 0)) {
+ if (nomagicopen
+ ? do_open6(gv, "<", 1, NULL, &GvSV(gv), 1)
+ : do_open6(gv, PL_oldname, oldlen, NULL, NULL, 0)
+ ) {
return IoIFP(GvIOp(gv));
}
}
@@ -1126,7 +1129,7 @@ Perl_do_eof(pTHX_ GV *gv)
PerlIO_set_cnt(IoIFP(io),-1);
}
if (PL_op->op_flags & OPf_SPECIAL) { /* not necessarily a real EOF yet? */
- if (gv != PL_argvgv || !nextargv(gv)) /* get another fp handy */
+ if (gv != PL_argvgv || !nextargv(gv, FALSE)) /* get another fp handy */
return TRUE;
}
else