Subject: Re: more user-friendly error message for /bin/sh?
To: None <>
From: Alan Barrett <>
List: tech-userlevel
Date: 01/18/2007 13:03:04
On Wed, 17 Jan 2007, James K. Lowden wrote:
> > I thought that the most common scenario was: binary is for the wrong
> > OS, the wrong hardware, or needs a kernel option that's not enabled
> With respect, Alan, I think you're letting your fertile imagination
> run away with this idea.  You already cooked up scenarios I hadn't
> thought of.  But "common"?

I really do think that, in the cases where I have personally encountered
this problem, the sequence of events has usually involved a binary that
the kernel couldn't exec.  Remember that there was a time when kernels
did not understand shebang lines, and shells reacted to ENOEXEC by
trying to interpret the shebang line, or fall back to passing the file
to some default shell.  The fallback code in the shells lived on long
past the time when kernels gained the ability to exec scripts.  Even
today, NetBSD's /bin/sh has code to do that, disabled if defined(BSD);
and NetBSD's /bin/csh reacts to ENOEXEC by trying to interpret the file
as a script, but at least it first checks whether it looks like binary.

> The '"(" unexpected' message was recognized by more than one person as
> an indication that the shell was trying to interpret an ELF binary.
> How many others would be so recognized?  Surely that's evidence of its
> prevalence.

I recognise the '")" unexpected' message as an indication that the shell
is trying to interpret a binary.  This has been happening for ages,
since before ELF even existed.  Maybe today ELF is the most common, but
who knows about tomorrow?

> I said Roland's little patch makes things better, and you agree, no?
> No one's said it wouldn't be useful, only that it wouldn't be useful
> *enough*, which to me is making the perfect the enemy of the good.

I don't object to the patch, so I don't think I can reasonably be said
to be making the perfect the enemy of the good.  I do think it would be
more useful to check for anything that doesn't look like text, instead
of only checking for ELF, but that needn't stop anybody from committing
the patch as is.

--apb (Alan Barrett)