9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] #!/bin/foo
@ 2005-07-14 21:09 arisawa
  2005-07-15 18:30 ` Dan Cross
  0 siblings, 1 reply; 4+ messages in thread
From: arisawa @ 2005-07-14 21:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello

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?

Kenji Arisawa



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] #!/bin/foo
  2005-07-14 21:09 [9fans] #!/bin/foo arisawa
@ 2005-07-15 18:30 ` Dan Cross
  2005-07-15 22:08   ` arisawa
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Cross @ 2005-07-15 18:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, Jul 15, 2005 at 06:09:11AM +0900, arisawa@ar.aichi-u.ac.jp 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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] #!/bin/foo
  2005-07-15 18:30 ` Dan Cross
@ 2005-07-15 22:08   ` arisawa
  2005-07-15 22:40     ` arisawa
  0 siblings, 1 reply; 4+ messages in thread
From: arisawa @ 2005-07-15 22:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> 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.

Thanks for your interest.

Yes I know that, but I have experienced such an endless loop
using only binary executables. the kernel crushed.
of course the logic was not so simple.

> 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.
>

that is easy but dirty.

Kenji Arisawa



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] #!/bin/foo
  2005-07-15 22:08   ` arisawa
@ 2005-07-15 22:40     ` arisawa
  0 siblings, 0 replies; 4+ messages in thread
From: arisawa @ 2005-07-15 22:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I said:

> Yes I know that, but I have experienced such an endless loop
> using only binary executables. the kernel crushed.
> of course the logic was not so simple.
>

sorry, the situation might have been somewhat different.

the current kernel codes manipulates both executable binary
and executable script in exec system call.
how about bringing executable script parts to library ?
that is, introducing low level _exec that handles only binary
and we have exec in libray.
then, I guess, we can get more flexibility.

Kenji Arisawa



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-15 22:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-14 21:09 [9fans] #!/bin/foo arisawa
2005-07-15 18:30 ` Dan Cross
2005-07-15 22:08   ` arisawa
2005-07-15 22:40     ` arisawa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).