summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-30 20:13:29 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-30 20:30:44 -0800
commitb7e077d0225eac833ce2eb6fe9e1807f77d0f848 (patch)
treead34593e9ff058ece07feabe1d6c8f9d37c3d827 /t/run
parentb3adf4c04b682aa1b048bc826d019a355ea7637d (diff)
downloadperl-b7e077d0225eac833ce2eb6fe9e1807f77d0f848.tar.gz
[perl #104288] Die with ‘Unrecognized switch’ on #! line
If a switch such as -x that cannot occur on the shebang line is used there, perl dies with ‘Can’t emulate...’. If an unrecognised switch is used on the command line, perl dies with ‘Unrecognized switch...’. It just happens to use the former error message for unrecognized switches on the shebang line, which can be confusing: $ perl -e '#!perl -G' Can't emulate -G on #! line at -e line 1. This commit changes it to output the same message as command-line switches for those that are unrecognised wherever they are used.
Diffstat (limited to 't/run')
-rw-r--r--t/run/switches.t16
1 files changed, 15 insertions, 1 deletions
diff --git a/t/run/switches.t b/t/run/switches.t
index f636cea43e..419d580d4d 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -11,7 +11,7 @@ BEGIN {
BEGIN { require "./test.pl"; }
-plan(tests => 71);
+plan(tests => 110);
use Config;
@@ -297,6 +297,20 @@ foreach my $switch (split //, "ABbGgHJjKkLNOoPQqRrYyZz123456789_")
qr/\QUnrecognized switch: -$switch (-h will show valid options)./,
"-$switch correctly unknown" );
+ # [perl #104288]
+ like( runperl( stderr => 1, prog => "#!perl -$switch" ),
+ qr/^Unrecognized switch: -$switch \(-h will show valid (?x:
+ )options\) at -e line 1\./,
+ "-$switch unrecognised on #! line" );
+}
+
+# Tests for unshebangable switches
+for (qw( e f x E S V )) {
+ $r = runperl(
+ stderr => 1,
+ prog => "#!perl -$_",
+ );
+ is $r, "Can't emulate -$_ on #! line at -e line 1.\n","-$_ on #! line";
}
# Tests for -i