In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1d5bb6ba43b89f3f2c4b12f033b9c0659f35fbdc?hp=cffd634c5d3a829d6a33c6ed44efd8a8dfbaf2aa>
- Log ----------------------------------------------------------------- commit 1d5bb6ba43b89f3f2c4b12f033b9c0659f35fbdc Merge: cffd634 684b0ec Author: Tony Cook <[email protected]> Date: Tue Jul 23 10:24:45 2013 +1000 [perl #116190] -F implies -a, either implies -n Previously -F without -a was a no-op, and -a without -n or -p was a no-op, with this change, if you supply -F then both -a and -n are implied (you can still use -p for its extra behaviour), and if you supply -a then -n is implied. commit 684b0ecaad281760b04dd2da317ee0459cafebf6 Author: Tony Cook <[email protected]> Date: Tue Jul 16 14:57:20 2013 +1000 [perl #116190] feed an empty stdin to run_multiple_progs() programs Two tests for -a were attempting to read stdin and blocking with the -a implies -n change. M t/test.pl commit 24ffa3099a4f0f4904129f4f4633846134d0b51f Author: Tony Cook <[email protected]> Date: Tue Jul 16 12:11:55 2013 +1000 [perl #116190] -F and -a now imply -n M perl.c M pod/perlrun.pod M t/run/switchF2.t commit 3271c5f82f49e4fe01b86ca11bb7305e0b5ba12a Author: Tony Cook <[email protected]> Date: Tue Jul 16 12:00:41 2013 +1000 [perl #116190] use the true and trusted fresh_perl_is() instead of re-inventing it yet again M t/run/switchF2.t commit 5fc691f12365580534cea1c0be21bed7badfb89a Author: Aristotle Pagaltzis <[email protected]> Date: Wed Jan 9 11:26:56 2013 +0100 Make the -F switch imply -a M MANIFEST M perl.c A t/run/switchF2.t ----------------------------------------------------------------------- Summary of changes: MANIFEST | 1 + perl.c | 3 +++ pod/perlrun.pod | 10 +++++++--- t/run/switchF2.t | 26 ++++++++++++++++++++++++++ t/test.pl | 3 ++- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 t/run/switchF2.t diff --git a/MANIFEST b/MANIFEST index c2c3882..8fb53e0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5367,6 +5367,7 @@ t/run/switchd-78586.t See whether bug 78586 is fixed t/run/switchd.t Test the -d switch t/run/switches.t Tests for the other switches (-0, -l, -c, -s, -M, -m, -V, -v, -h, -z, -i) t/run/switchF1.t Pathological tests for the -F switch +t/run/switchF2.t Pathological tests for the -F switch t/run/switchF.t Test the -F switch t/run/switchI.t Test the -I switch t/run/switchM.t Test the -M switch diff --git a/perl.c b/perl.c index ee36fd1..5458c1d 100644 --- a/perl.c +++ b/perl.c @@ -3213,13 +3213,16 @@ Perl_moreswitches(pTHX_ const char *s) PL_utf8cache = -1; return s; case 'F': + PL_minus_a = TRUE; PL_minus_F = TRUE; + PL_minus_n = TRUE; PL_splitstr = ++s; while (*s && !isSPACE(*s)) ++s; PL_splitstr = savepvn(PL_splitstr, s - PL_splitstr); return s; case 'a': PL_minus_a = TRUE; + PL_minus_n = TRUE; s++; return s; case 'c': diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 05dea4e..dbaa12c 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -265,6 +265,8 @@ is equivalent to An alternate delimiter may be specified using B<-F>. +B<-a> implicitly sets B<-n>. + =item B<-C [I<number/list>]> X<-C> @@ -487,9 +489,11 @@ perl, you can check the value of C<$Config{usesitecustomize}>. =item B<-F>I<pattern> X<-F> -specifies the pattern to split on if B<-a> is also in effect. The -pattern may be surrounded by C<//>, C<"">, or C<''>, otherwise it will be -put in single quotes. You can't use literal whitespace in the pattern. +specifies the pattern to split on for B<-a>. The pattern may be +surrounded by C<//>, C<"">, or C<''>, otherwise it will be put in single +quotes. You can't use literal whitespace in the pattern. + +B<-F> implicitly sets both B<-a> and B<-n>. =item B<-h> X<-h> diff --git a/t/run/switchF2.t b/t/run/switchF2.t new file mode 100644 index 0000000..a411711 --- /dev/null +++ b/t/run/switchF2.t @@ -0,0 +1,26 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} +plan(tests => 3); + +{ # perl #116190 + fresh_perl_is('print qq!@F!', '1 2', + { + stdin => "1:2", + switches => [ '-n', '-F:' ], + }, "passing -F implies -a"); + fresh_perl_is('print qq!@F!', '1 2', + { + stdin => "1:2", + switches => [ '-F:' ], + }, "passing -F implies -an"); + fresh_perl_is('print join q!,!, @F', '1,2', + { + stdin => "1 2", + switches => [ '-a' ], + }, "passing -a implies -n"); +} diff --git a/t/test.pl b/t/test.pl index 41efbb8..eb4f868 100644 --- a/t/test.pl +++ b/t/test.pl @@ -1134,7 +1134,8 @@ sub run_multiple_progs { print $fh "\n#line 1\n"; # So the line numbers don't get messed up. print $fh $prog,"\n"; close $fh or die "Cannot close $tmpfile: $!"; - my $results = runperl( stderr => 1, progfile => $tmpfile, $up + my $results = runperl( stderr => 1, progfile => $tmpfile, + stdin => '', $up ? (switches => ["-I$up/lib", $switch], nolib => 1) : (switches => [$switch]) ); -- Perl5 Master Repository
