Z
Ô
I
O
N

Erlkönig: Commandname Extensions Considered Harmful

Some complementary material on interpreter directives can be found in Wikipedia

Herein, a problem with filename extensions is described in a manner perhaps more pragmatic than, yet inspired by, the well known Go To Statement Considered Harmful by Edsger W. Dijkstra (Communications of the ACM, Vol. 11, No. 3, March 1968). Dijkstra's work addresses the issue of how the use of the go to statement largely abridges the ability to parametrically describe the progress of a process, engendering an unnecessary impediment to the code's clarity and manageability. This new document details, based on practical experience under Unix-like operating systems, how filename extensions, particularly but not limited to those files implementing commands, create a secondary set of semantic tags in the interfaces between between programs which are demonstrably both superfluous and treacherous.

Consider the following example, which a file is name with a .sh extension, to indicate the type of the file as well as to make it easy to list all files of the same type (shell scripts).

$ ./frob.sh
hello world
$ ls *sh
frob.sh
$ sh frob.sh
frob.sh: line 2: use: command not found
hello world
$ cat frob.sh
#!/usr/bin/perl -w
use strict;
printf "hello world\n";
$  

Such a file is typical of scripts written by relatively inexperienced users of Unix, where the code has been later reimplemented but the filename left unaltered for backwards compatibility. The surprises in the second two commands should be self-evident, and are the focus of what follows.

Three common mechanisms exist within Unix to determine how a file should be processed as a set of directives: