[lkml]   [1997]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject"What is the !@#$ pathname of Perl on *this* machine?"
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

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

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

 \ /
  Last update: 2005-03-22 13:39    [W:1.517 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site