On Fri, Jul 15, 2005 at 06:09:11AM +0900, [EMAIL PROTECTED] wrote:
> A file with a executable bit and a starting line
> #!/bin/foo
> is executable if foo is executable binary.
> But the file fails execution if foo is a script.
> Isn't this inconvenient?

It is, but it's to prevent an endless loop....  Imagine if you had a
script named /usr/someone/blah that started, ``#!/usr/someone/blah''.
It would try to recursively start itself as a script, and the kernel
would (potentially) go into an endless loop.  Of course, it would be
silly and pathological for someone to do something as simple as this on
purpose, but one could imagine a circular graph being inadventantly
created out of a chain of interpreters that did the same thing (e.g.,
interp1 calls interp2 that calls interp3 that calls interp1 again).

You could try and prevent it by setting a counter in the kernel of the
number of times you've invoked an interpreter when trying to run a
program, but that could potentially break down, so it was probably
deemed easier to just prevent the whole practice.

Under Unix, you could probably get around it by doing something like,
#!/usr/bin/env script-to-use-as-interpreter.  Some similar wrapper
could probably be written for Plan 9 to achieve the same effect.

        - Dan C.

Reply via email to