9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Dan Cross <cross@math.psu.edu>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] #!/bin/foo
Date: Fri, 15 Jul 2005 14:30:06 -0400	[thread overview]
Message-ID: <20050715183006.GA21802@augusta.math.psu.edu> (raw)
In-Reply-To: <aa47b632762c98bb2fcc239a5ae17eef@ar.aichi-u.ac.jp>

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.



  reply	other threads:[~2005-07-15 18:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-14 21:09 arisawa
2005-07-15 18:30 ` Dan Cross [this message]
2005-07-15 22:08   ` arisawa
2005-07-15 22:40     ` arisawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050715183006.GA21802@augusta.math.psu.edu \
    --to=cross@math.psu.edu \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).