Please sign in to comment.
Make stacked -l work
Perl 5.10.0 introduced stacked filetest operators, -x -r $foo being equivalent to -r $foo && -x _ That does not work with -l. It was these suspicious lines in Perl_my_lstat_flags that drew my attention to it: > else if (PL_laststype != OP_LSTAT > && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO)) > Perl_croak(aTHX_ no_prev_lstat); That croak only happens when warnings are on. Warnings are just supposed to be warnings, unless the ‘user’ explicitly requests fatal warnings. $ perl -le 'print "foo", -l -e "miniperl"' foo $ perl -lwe 'print "foo", -l -e "miniperl"' The stat preceding -l _ wasn't an lstat at -e line 1. That it doesn’t die in the first example is a bug. In fact, it’s using the return value of -e as a file name: $ ln -s miniperl 1 $ ./miniperl -le 'print -l -e "miniperl"' 1 And, with warnings on, if the preceding stat *was* an lstat, it falls back to the pre-stacked behaviour, just as it does when warn- ings are off. It’s meant to be equivalent to -e "miniperl" && -l _ (which is why the error message above says ‘The stat preceding -l _’).
- Loading branch information...
Showing with 36 additions and 3 deletions.