Subject: Re: misc/23729: Syntax error: "(" unexpected
To: None <gnats-bugs@NetBSD.org, misc-bug-people@netbsd.org,>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 10/08/2006 22:10:15
On Oct 8,  1:10am, dholland@eecs.harvard.edu (David Holland) wrote:
-- Subject: Re: misc/23729: Syntax error: "(" unexpected

| The following reply was made to PR misc/23729; it has been noted by GNATS.
| 
| From: dholland@eecs.harvard.edu (David Holland)
| To: gnats-bugs@NetBSD.org
| Cc: 
| Subject: Re: misc/23729: Syntax error: "(" unexpected
| Date: Sat, 7 Oct 2006 21:07:25 -0400 (EDT)
| 
|  As of now, the only widely used shells that try to run files that
|  won't exec() are sh and ksh. All the others fail, which you can verify
|  by taking your favorite hello.c, compiling, and then editing the
|  binary to replace "ld_elf.so" with, say, "ld_alf.so". This produces
|  these results:
|  
|     % csh -c ./hullo 
|     ./hullo: Exec format error. Wrong Architecture.
|  
|     % bash -c ./hullo 
|     bash: ./hullo: cannot execute binary file
|  
|     % tcsh -c ./hullo 
|     ./hullo: Exec format error. Binary file not executable.
|  
|     % zsh -c ./hullo 
|     zsh: exec format error: ./hullo
|  
|  and
|  
|     % sh -c ./hullo 
|     ./hullo: 1: Syntax error: "(" unexpected
|  
|     % ksh -c ./hullo 
|     ./hullo: 1: Syntax error: "(" unexpected
|  
|  The behavior exhibited by sh and ksh is historic, but hasn't been
|  useful since #! was invented, which was a long time ago.
|  
|  Probably the best thing to do is to remove it.

And what happens to shell scripts that don't start with #!?

christos