diff options
author | Rafael Garcia-Suarez <rgs@consttype.org> | 2014-07-24 17:43:29 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2014-09-30 08:17:50 +0200 |
commit | 157fb5a14d10ed16ffc6ebfc43d2637a016fdfce (patch) | |
tree | b2410287e269d41f3295678586e62ce4fa459188 /doio.c | |
parent | f276fdad8f6660f36944c895587a7748585e4969 (diff) | |
download | perl-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.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 |