"What is the !@#$ pathname of Perl on *this* machine?"

Dale R. Worley (worley@ariadne.com)
Wed, 19 Feb 1997 09:39:49 -0500


I've implemented a feature to allow the path names of interpreter
programs in '#!' lines to be abbreviated (and thus,
machine-independent). Could some people comment on the concept and
check out the implementation?

"What is the !@#$ pathname of Perl on *this* machine?"

Like most users in multi-machine environments, I've had to fight with
the problem of getting the pathnames in the '#!' lines of scripts
right -- the pathname of Perl, or sh, or csh, is never quite the same
when you go from machine to machine. (Though you can usually rely on
/bin/sh.) Even worse is when the script is NFS-mounted on several
machines, but the pathname of the interpreter is different on the
different machines.

To give an idea of the size of the problem, I scanned my fairly
vanilla Linux system (kernel 2.0.23, Slackware 3.1) for scripts and
checked whether the '#!' lines were valid. The results are that 461
of 460 references to sh/bash are valid, 8 of 8 references to csh are
valid, but only 108 of 154 references to perl are valid.

For years, I've wanted to solve this problem, and now with Linux I've
been able to implement a solution: the "list of registered
interpreters".

The basic idea is that if the interpreter name in a '#!' line is a
single name (rather than a pathname), the kernel will consult an
internal list of "registered interpreters" to translate the name into
a pathname. This allows the mapping from interpreter names to
executable paths to vary from machine to machine. And since people
never write relative paths into '#!' lines, this is upward compatible
from current practice.

The kernel list of registered interpreters is manipulated through a
special file, /proc/interpreters, using a program 'interpctl'.
Normally, interpctl is used to load a standard list of interpreter
paths at startup time. Once you have a given interpreter name
registered correctly on all your machines, a script can use the short
name in its '#!' line and will execute correctly on all machines.

The kernel patches, user-level programs, and manual pages for the
registered interpreter list system are available from
ftp://ftp.std.com/consultants/Ariadne/interp-path/

Dale

--
Dale R. Worley					Ariadne Internet Services
Voice: +1 617-899-7949   Fax: +1 617-899-7946	E-mail: worley@ariadne.com
"Internet-based electronic commerce solutions to real business problems."