From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Bug in shell.el: explicit-bash-args does not work for bash 1.x Date: 27 Oct 2002 02:17:56 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <5x1y6cg2ff.fsf@kfs2.cua.dk> References: <5xn0p2mw3z.fsf@kfs2.cua.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035674385 4186 80.91.224.249 (26 Oct 2002 23:19:45 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 26 Oct 2002 23:19:45 +0000 (UTC) Cc: schwab@suse.de, emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 185aDX-00015D-00 for ; Sun, 27 Oct 2002 01:19:43 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 185aGu-00060d-00 for ; Sun, 27 Oct 2002 01:23:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 185aC6-0000D2-00; Sat, 26 Oct 2002 19:18:14 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 185aBk-0008RJ-00 for emacs-devel@gnu.org; Sat, 26 Oct 2002 19:17:52 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 185aBj-0008Qq-00 for emacs-devel@gnu.org; Sat, 26 Oct 2002 19:17:52 -0400 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10) id 185aBi-0008Qk-00; Sat, 26 Oct 2002 19:17:50 -0400 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id 40E0E7C017; Sat, 26 Oct 2002 23:17:49 +0000 (GMT) Original-To: rms@gnu.org In-Reply-To: Original-Lines: 47 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:8827 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:8827 Richard Stallman writes: > However, for bash 1.x (included with e.g. redhat 6.2), the --noediting > option isn't recognized and bash refuses to start. > > That is fairly old. I don't think we should drop the feature > just for the sake of old systems. Is there a way to detect the > error and start bash again in a suitable way for bash 1.x? > The following code returns the proper setting for bash 1.x and 2.x. I suppose it could be used as the initial value for explicit-bash-args. (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name) (getenv "ESHELL") shell-file-name)) (name (file-name-nondirectory prog))) (if (and (equal name "bash") (file-executable-p prog) (string-match "bad option" (shell-command-to-string (concat prog " --noediting")))) '("-i") '("--noediting" "-i"))) It is optimized to run (when shell.el is loaded) only if the configured shell is actually bash, meaning that it isn't set properly if the user later changes from some other shell to bash after loading shell.el. If that behaviour is not acceptable, we can check for bash explicitly and set the option unconditionally: (if (string-match "bad option" (shell-command-to-string "/bin/bash --noediting")) '("-i") '("--noediting" "-i")) However, that assumes that bash 1.x is located in /bin/bash for the proper [reduced] setting is selected -- probably a reasonable assumption, and still not much harm done if it makes the wrong choice. -- Kim F. Storm http://www.cua.dk