[Catalyst] Remove .pl from scripts?

Jules Bean jules at jellybean.co.uk
Sat Nov 19 18:50:34 CET 2005


Christopher H. Laco wrote:
>> Fix your editor. Or use a better one. This is the 21st century you know.
> 
> How about some more fact rather than a quip?

My apologies. It was not intended to be a quip, just rather brief and to 
the point.

> I believe SciTE is a rather well known non broken editor in that
> reqpest. I would wager that the majority of all editors check the file
> extension as the very first check in mapping files to languages and
> language parsers.

Well the important point is actually how the *operating system* will 
decides it's a perl file. Since my operating systems (that is, the ones 
I am familiar with using) do that by checking the shebang, so does my 
editor. Seems sensible to me. I have no idea how win32 does this. I 
daresay win32 can be configure to push all script files through an 
installed copy of bash, and bash like most shells will notice the 
shebang and exec() perl. I've never used SciTE (hadn't heard of it until 
today), I glanced at the web page, it looks pretty good so I'm rather 
surprised if it can't set modes based on the first line of the code, but 
maybe it can't.


>> I find nothing 'ambiguous' about the name without the .pl.
> 
> How is that?
> 
> Here's a file:  /usr/local/myfile
> 
> What is it? Yup, you can't tell without opening it first, or TRYING to
> run it. If it has no shebang of execute bit, you're screwed. Now you
> have to open it to figure out how to run it.

Personally, I run the 'file' utility, as in 'file /usr/local/myfile'. 
Sample output on a reasonable assortment of files I happen to have lying 
around:

Microsoft Office Document
ASCII English text
TIFF image data, big-endian
JPEG image data, EXIF standard, comment: "AppleMark"
JPEG image data, EXIF standard 2.2
JPEG image data, JFIF standard 1.01
PDF document, version 1.5
MS-DOS executable (EXE), OS/2 or MS Windows
PostScript document text conforming at level 2.0
TeX DVI file (TeX output 2004.12.01:1940\213)
XML document text
gzip compressed data, was "Archive.tar", from Unix
perl script text executable
Perl5 module source text
HTML document text
PNG image data, 171 x 244, 8-bit colormap, non-interlaced
Mach-O executable ppc


...and so on.

In fact most sensible file formats (including shebang executables, but 
also including PNG, JPEG, ELF executables, and so on) have information 
in the first few bytes which uniquely identify the file type. I would 
content that this is much more robust than depending on file extensions 
which anyone can change.

Jules







More information about the Catalyst mailing list