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

. Tethys (tethys@lonnds.ml.com)
Thu, 20 Feb 1997 16:59:09 +0000


> Why do you assume that "people never write relative paths into
> '#!' lines"? I just tried it, and it works quite well; perhaps
> there is someone somewhere who depends on it. I suggest having
> a special prefix, such as "#!?perl", to tell your code to look
> up perl in the list.
>
>Well, I've never seen nor heard of anyone writing relative paths.

I'm afraid that I *have* seen this, usually in scripts that are designed
to be called from another script or program, where the calling directory
should be constant.

>But I do like the idea of having a special prefix character. What
>characters do you think would be good? Of course, there are no
>characters which are invalid for pathname (other than NUL), so we
>still can't avoid messing up something that someone might be doing
>somewhere.

Not quite. Anything that doesn't contain a '/' character isn't a valid
pathname. Thus anything in this category should be treated as the name
of an interpreter, which can then be validated against the list of
registered interpreters (or even just checked to see if it's in the
current PATH, although that could raise security issues).

Tet

PS. Yes, that still doesn't cover the case where an interpreter is in
the current directory, and the script uses "#!xyz" rather than
"#!./xyz", but if someone's doing that, they deserve their system
to break!

--
``Anyone who cannot cope with mathematics is not fully human. He is at
  best a tolerable subhuman who has learned to wear shoes, bathe and
  not make messes in the house.''      -- from the notebooks of Lazarus Long
--------------------+--------------+----------------------------------------
tethys@ml.com       |  Micro$oft:  | Linux,  the choice of a GNU generation.
tet@astradyne.co.uk | Just say no! | See http://www.uk.linux.org for details