From owner-freebsd-bugs@FreeBSD.ORG Sat Apr 4 23:30:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28880106566B for ; Sat, 4 Apr 2009 23:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 15E938FC0A for ; Sat, 4 Apr 2009 23:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n34NU2nK089213 for ; Sat, 4 Apr 2009 23:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n34NU2bH089210; Sat, 4 Apr 2009 23:30:02 GMT (envelope-from gnats) Date: Sat, 4 Apr 2009 23:30:02 GMT Message-Id: <200904042330.n34NU2bH089210@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: bin/21315: Shells often behave oddly when executing shell scripts X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 23:30:03 -0000 The following reply was made to PR bin/21315; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, rwatson@freebsd.org Cc: Subject: Re: bin/21315: Shells often behave oddly when executing shell scripts Date: Sun, 5 Apr 2009 01:22:34 +0200 > Shells appear to behave oddly when executing shell scripts in a number > of situations. > (1) When the kernel discovers that the interpreter used is another > interpreter, it generally returns ``Exec format error'' (ENOEXEC). > However, when csh and sh find themselves in the same situation, they > don't return that error, they execute the script using their own > interpreter. In the case of sh, POSIX says that it should do this. If sh gets ENOEXEC or equivalent when it tries to execute something, it should execute the file as a shell script. Only if the file is not a text file may sh refuse to execute it, writing an error message and returning an exit status of 126. (Our sh does not use this exception, resulting in messages like '1: Syntax error: "(" unexpected' when trying to execute an ELF binary for a different architecture.) > (2) When in single-user mode, the sh shell appears to assume that any > script it runs should be executed using its own interpreter, not the > interpreter at the top of the file. In multi-user mode, this appears > to work fine. I have no idea about this, but it could have something to do with ENOEXEC as well. In particular, when this PR was written, ld-elf.so.1 was in /usr/libexec, so unavailable when /usr was not mounted. -- Jilles Tjoelker