]> git.donarmstrong.com Git - perltidy.git/commitdiff
modify check to avoid false hash-bang warning
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 18 Sep 2020 15:53:19 +0000 (08:53 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 18 Sep 2020 15:53:19 +0000 (08:53 -0700)
lib/Perl/Tidy/Tokenizer.pm

index 35d18d42f2884dcba1d550b834ef2037052b711c..4fbb54d6bbf3a3b57db1831901da7dd09301cd75 100644 (file)
@@ -824,9 +824,20 @@ sub get_line {
                 )
                 && !$tokenizer_self->[_look_for_hash_bang_]
 
-               # Patch: be sure there is either a slash or the word 'perl'
-               # after the #! before giving a warning.
-                && $input_line =~ /^\#\!\s*(\/|perl)/ 
+                # Try to avoid giving a false alarm at a simple comment. 
+                # These look like valid hash-bang lines:
+
+                #!/usr/bin/perl -w
+                #!   /usr/bin/perl -w
+                #!c:\perl\bin\perl.exe
+
+                # These are comments:
+                #! I love perl
+                #!  sunos does not yet provide a /usr/bin/perl
+
+                # Comments typically have multiple spaces, which suggests
+                # the filter
+                && $input_line =~ /^\#\!(\s+)?(\S+)?perl/ 
               )
             {