Re: Bug in #! processing (long reply)

From: David G. Lawrence <dg_at_dglawrence.com>
Date: Sat, 2 Oct 2004 16:35:42 -0700
> fact, it seems to be the '--' which is causing the rest of the
> line to be ignored, not the '#'.
> 
> The PR is correct in that this feature is documented by perl books,
> but the right way to support the feature is to change /bin/sh and
> not the command interpreter.  The PR includes a followup reply from
> Ahmon Dancy <dancy_at_dancysoft.com> with some additional proof that
> the change to the command interpreter was the wrong way to fix this.
> 
> Since this perl feature is documented in many places (including the
> famous "Camel" book from O'Reilly), we can not just drop the support
> in the command interpreter.  But if we first fix /bin/sh then I
> believe we can drop it.

   Err, your terminology is a bit off (/bin/sh is the "command interpreter");
what we're talking about is the behavior of the execve() system call in the
kernel, specifically the imgact_shell image activation module. When the
system sees that a file needs to be interpreted by something (e.g. sh, perl,
python, or some other language interpreter) it parses the interpreter line
specified at the top of the file (#!/bin/sh) and sets up to invoke that with
the original file as the argument.
   ...but I see what you're saying and I agree with the thought. The
interpreter should decide if the # is a comment, not the kernel.

-DG

David G. Lawrence
President
Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500
TeraSolutions, Inc. - http://www.terasolutions.com - (888) 346 7175
The FreeBSD Project - http://www.freebsd.org
Pave the road of life with opportunities.
Received on Sat Oct 02 2004 - 21:36:03 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:15 UTC