Skip to contentSkip to conversation

binfmt_script and ^M

DISCUSSION Jesse Pollard 2 participants 2 messages Mar 6, 2001

lore
Share & tools
lore
#0 lore raw

Andreas Schwab <[email protected]>:Andreas Schwab <[email protected]>Andreas Schwab <[email protected]>

Quoted 17 lines

Paul Flinders <[email protected]> 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?
Quoted 7 lines

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.

IFS can be defined in the environment.

The kernel cannot use that definition because it introduces buffer limits and a potential overflow. Besides, the kernel can run scripts from applications that may not have or pass IFS, or it's equivalent in whatever shell is being used (I seem to remember an Icon shell that used commas).

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: [email protected]

Any opinions expressed are solely my own.

#1 lore raw

Jesse Pollard <[email protected]> writes:

|> Andreas Schwab <[email protected]>:Andreas Schwab <[email protected]>Andreas Schwab <[email protected]>
|> > Paul Flinders <[email protected]> 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.
|> 
|> IFS can be defined in the environment.

No, the shell won't import it.

Andreas.

Signature · 5 lines
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
[email protected]
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5