atom / language-perl

Perl package for Atom
Other
25 stars 32 forks source link

Perl hashbang doesn't trigger autodetection correctly for files called install. #85

Open mscharley opened 7 years ago

mscharley commented 7 years ago

Prerequisites

Description

The #!/usr/bin/env perl hashbang doesn't trigger Perl as the autodetected language. In my setup it defaults to PHP instead.

Steps to Reproduce

  1. Create a new file called install.

  2. Add the following code to the file:

    #!/usr/bin/env perl
    use strict;
  3. Set the file type to "Autodetect".

Expected behavior: The autodetected language is Perl.

Actual behavior: The autodetected language is PHP.

Reproduces how often:

100% reproduction with the filename install. Seems to be tied to this specific filename and I'm not sure why - I tried install.pl and foo and both got autodetected correctly as Perl files.

Versions

Atom    : 1.15.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0
winstliu commented 7 years ago

https://github.com/atom/language-php/blob/7fc557ace292af28d47dad7a20356276c9367c05/grammars/php.cson#L7

Filenames take priority over shebangs currently.

mscharley commented 7 years ago

Damn, a file called simply install is still registered as being a file of type install. That's an unfortunate conflict, but I imagine it's probably necessary to handle things like Rakefile and similar that are just bare names.

For context, https://github.com/mscharley/dotfiles/blob/master/install.pl which I've simply renamed for now. Maybe this should be an issue against atom/language-php then because I do know that some PHP frameworks use *.install frequently. Still seems like a bad idea to take over all files called install though.