This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-l followed by bareword should leave the stack alone
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Sep 2011 21:02:45 +0000 (14:02 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 10 Sep 2011 22:49:10 +0000 (15:49 -0700)
commitca86716259195ac20de0ed1daf63e90535e872c0
tree78349a584ab8cc88493409ae9c1c61cae13414f4
parent93e94d8ade64ced372985ff8643fa9a4e05d6e90
-l followed by bareword should leave the stack alone

$ ln -s /usr/bin/perl bar
$ perl -le' print "bar", -l foo'
1

The -l ate my bar.

It’s this naughty piece of code in doio.c:Perl_my_lstat_flags that is
the culprit:

  if (ckWARN(WARN_IO)) {
      Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
      GvENAME(cGVOP_gv));
      return (PL_laststatval = -1);
  }

When -l is followed by a bareward, it has no argument on the stack,
but the filetest op itself is a gvop.  That snippet is from the bare-
word-handling code.

So, if warnings are off, it falls through to the argument-on-the-stack
code and pops off something does not belong to it (that belong to the
print, in the example above).
doio.c
t/op/filetest.t