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: 29 Oct 2002 00:29:30 +0100 Sender: emacs-devel-admin@gnu.org Message-ID: <5x65vmw3ad.fsf@kfs2.cua.dk> References: <5xn0p2mw3z.fsf@kfs2.cua.dk> <5x1y6cg2ff.fsf@kfs2.cua.dk> <200210282148.g9SLm2711909@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035844432 17477 80.91.224.249 (28 Oct 2002 22:33:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 28 Oct 2002 22:33:52 +0000 (UTC) Cc: rms@gnu.org, 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 186ISF-0004Xl-00 for ; Mon, 28 Oct 2002 23:33:51 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 186IWZ-0002ET-00 for ; Mon, 28 Oct 2002 23:38:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 186IOu-0005x4-00; Mon, 28 Oct 2002 17:30:24 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 186IO6-0004cm-00 for emacs-devel@gnu.org; Mon, 28 Oct 2002 17:29:34 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 186IO4-0004aT-00 for emacs-devel@gnu.org; Mon, 28 Oct 2002 17:29:33 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10) id 186IO3-0004Yh-00; Mon, 28 Oct 2002 17:29:31 -0500 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id CCD7A7C018; Mon, 28 Oct 2002 22:29:29 +0000 (GMT) Original-To: "Stefan Monnier" In-Reply-To: <200210282148.g9SLm2711909@rum.cs.yale.edu> Original-Lines: 42 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:8862 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:8862 "Stefan Monnier" writes: > > (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"))) > > I must say I don't like the idea of running a program when loadng > a .el file. It's already done at various places, tho. > > There is no strong reason, but one of the recent problem I came > across in this area is that process operations don't work properly during > dumping (the handling of sigchld is explicitly not turned on because > it can supposedly prevent unexec from working right). > The following code doesn't execute the program; it does a brute-force check for the version of the bash program by looking inside the executeable. This works for me on GNU/Linux -- again, if it doesn't work on other platforms, it doesn't do any worse than the current default... (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) (file-readable-p prog) (with-temp-buffer (insert-file-contents-literally prog) (goto-char (point-min)) (search-forward "@(#)Bash version 1" nil t))) '("-i") '("--noediting" "-i"))) -- Kim F. Storm http://www.cua.dk