From: Don Dugger <n0ano@valinux.com>
To: Paul Flinders <P.Flinders@ftel.co.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: binfmt_script and ^M (historical note)
Date: Tue, 6 Mar 2001 10:17:33 -0800 [thread overview]
Message-ID: <20010306101733.L28504@valinux.com> (raw)
In-Reply-To: <20010305095512.A30787@tux.gsfc.nasa.gov> <Pine.LNX.4.21.0103051224450.5591-100000@imladris.rielhome.conectiva> <20010305105943.A25964@iglou.com> <3AA3BC4E.FA794103@ftel.co.uk> <jeae70m97e.fsf@hawking.suse.de> <3AA3EEDF.D0547D4@dawa.demon.co.uk> <jeae6zkwmy.fsf@hawking.suse.de> <3AA4D92D.CDDB764D@ftel.co.uk>
In-Reply-To: <3AA4D92D.CDDB764D@ftel.co.uk>; from P.Flinders@ftel.co.uk on Tue, Mar 06, 2001 at 12:33:49PM +0000
Paul-
Minor historical note. The `#!' processing was never done by the
shell, this was always done in the kernel. Think about about it,
the `#' character denotes a comment line, the shell ignores that
line. `#!' was used to create a way for the kernel to execute
a shell script directly. Since the kernel recognized the type of
executable based on a 16-bit magic number `#!' became a new magic
number that meant "break the remainder of the line into `program'
and `args' and then execute `program' with `args'".
A nice side effect of this is that it became a way to create shell
scripts that worked no matter what shell a user was running. For
efficiency, most shells just read and execute a shell script so
releasing a Bourne shell script to a group of CSH users created
problems. At the expense of a `fork' and `exec' the `#!' magic
number solved this problem.
On Tue, Mar 06, 2001 at 12:33:49PM +0000, Paul Flinders wrote:
> Andreas Schwab wrote:
>
> > Paul Flinders <paul@dawa.demon.co.uk> writes:
> >
> > |> Andreas Schwab wrote:
> > |>
> > |> > This [isspace('\r') == 1] has no significance here. The right thing to
> > |>
> > |> > look at is $IFS, which does not contain \r by default. The shell only splits
> > |>
> > |> > words by "IFS whitespace", and the kernel should be consistent with it:
> > |> >
> > |> > $ echo -e 'ls foo\r' | sh
> > |> > ls: foo: No such file or directory
> > |>
> > |> The problem with that argument is that #!<interpreter> can be applied
> > |> to more than just shells which understand $IFS, so which environment
> > |> variable does the kernel pick?
> >
> > The kernel should use the same default value of IFS as the Bourne shell,
> > ie. the same value you'll get with /bin/sh -c 'echo "$IFS"'. This is
> > independent of any settings in the environment.
> >
> > |> It's a difficult one - logically white space should terminate the interpreter
> >
> > No, IFS-whitespace delimits arguments in the Bourne shell.
>
> Way back whenever processing #! was moved from the
> shell to the kernel** this argument would have made sense -
> today I'm not so sure.
>
> But I'm quite happy for the kernel to use just space and
> tab if it wishes, or anything else for that matter but it _is_
> confusing that the error code doesn't distinguish problems
> with the script from problems with the interpreter.
>
> **Did linux ever rely on the shell for this?
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano@valinux.com
Ph: 303/938-9838
next prev parent reply other threads:[~2001-03-06 18:18 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-27 13:03 binfmt_script and ^M Ivo Timmermans
2001-02-27 13:44 ` Alan Cox
2001-02-27 13:47 ` Ivo Timmermans
2001-02-27 13:54 ` Alan Cox
2001-02-27 14:36 ` Rogier Wolff
2001-02-28 20:10 ` Erik Hensema
2001-03-01 12:04 ` Pavel Machek
2001-03-05 13:20 ` Jan Nieuwenhuizen
2001-03-05 13:37 ` Andreas Schwab
2001-03-05 13:40 ` Richard B. Johnson
2001-03-05 14:55 ` John Kodis
2001-03-05 15:25 ` Rik van Riel
2001-03-05 15:59 ` Jeff Mcadams
2001-03-05 16:18 ` Paul Flinders
2001-03-05 17:12 ` Andreas Schwab
2001-03-05 19:54 ` Paul Flinders
2001-03-05 20:09 ` Paul Flinders
2001-03-06 10:41 ` Andreas Schwab
2001-03-06 12:33 ` Paul Flinders
2001-03-06 14:45 ` Laramie Leavitt
2001-03-06 15:12 ` Sean Hunter
2001-03-06 15:37 ` David Weinehall
2001-03-06 21:10 ` Thorsten Glaser Geuer
[not found] ` <20010308130145.O20737@dev.sportingbet.com>
2001-03-09 16:52 ` Thorsten Glaser Geuer
2001-03-06 15:53 ` James A. Sutherland
2001-03-06 16:59 ` Xavier Bestel
2001-03-07 8:29 ` Ondrej Sury
2001-03-06 18:17 ` Don Dugger [this message]
2001-03-05 18:58 ` Pozsar Balazs
2001-03-05 20:39 ` Robert Read
2001-03-05 21:05 ` Pozsar Balazs
2001-03-05 22:34 ` Robert Read
2001-03-06 15:14 ` Jeff Coy
2001-03-06 18:15 ` Peter Samuelson
2001-03-06 18:36 ` Jeff Coy
2001-03-06 20:26 ` John Kodis
2001-03-06 20:43 ` Andreas Schwab
2001-03-06 2:18 ` Richard B. Johnson
2001-03-05 15:50 ` Richard B. Johnson
2001-03-05 16:53 ` H. Peter Anvin
2001-03-05 21:48 ` Dr. Kelsey Hudson
2001-03-06 18:19 ` Peter Samuelson
2001-03-06 21:04 ` Dr. Kelsey Hudson
2001-03-05 14:56 ` [PATCH]: print missing interpreter name [Was: Re: binfmt_script and ^M] Jan Nieuwenhuizen
2001-03-05 15:59 ` Richard B. Johnson
2001-03-05 20:18 ` [PATCH #3]: " Jan Nieuwenhuizen
2001-03-05 16:37 ` binfmt_script and ^M Erik Hensema
2001-03-05 22:13 ` Pavel Machek
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=20010306101733.L28504@valinux.com \
--to=n0ano@valinux.com \
--cc=P.Flinders@ftel.co.uk \
--cc=linux-kernel@vger.kernel.org \
/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