From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Rost Newsgroups: gmane.emacs.bugs Subject: bug#4616: 23.1.50; empty script files Date: Thu, 8 Oct 2009 19:43:32 +0200 (CEST) Message-ID: <20091008174333.11AC9EFE6B@sonic02.math.uni-bielefeld.de> Reply-To: Markus Rost , 4616@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1255027603 1131 80.91.229.12 (8 Oct 2009 18:46:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2009 18:46:43 +0000 (UTC) To: 4616@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 08 20:46:35 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Mvy0X-0004CW-C2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2009 20:46:33 +0200 Original-Received: from localhost ([127.0.0.1]:58436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mvy0W-0006tL-BF for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2009 14:46:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvxOX-0007Xc-FG for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2009 14:07:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvxOS-0007Po-BJ for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2009 14:07:16 -0400 Original-Received: from [199.232.76.173] (port=48560 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvxOS-0007PQ-51 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2009 14:07:12 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:39585) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MvxOR-0005jU-Ik for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2009 14:07:11 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n98I79Nw000619; Thu, 8 Oct 2009 11:07:09 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n98Ho4ba029749; Thu, 8 Oct 2009 10:50:04 -0700 Resent-Date: Thu, 8 Oct 2009 10:50:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Markus Rost Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Thu, 08 Oct 2009 17:50:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4616 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4616-submit@emacsbugs.donarmstrong.com id=B4616.125502382328947 (code B ref 4616); Thu, 08 Oct 2009 17:50:03 +0000 Original-Received: (at 4616) by emacsbugs.donarmstrong.com; 8 Oct 2009 17:43:43 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mail2.math.uni-bielefeld.de (mail2.math.uni-bielefeld.de [129.70.14.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n98HhfpE028944 for <4616@emacsbugs.donarmstrong.com>; Thu, 8 Oct 2009 10:43:42 -0700 Original-Received: from sonic02.math.uni-bielefeld.de (sonic02.math.uni-bielefeld.de [129.70.14.134]) by mail2.math.uni-bielefeld.de (Postfix) with ESMTP id A42B57304B; Thu, 8 Oct 2009 19:43:35 +0200 (CEST) Original-Received: by sonic02.math.uni-bielefeld.de (Postfix, from userid 3710) id 11AC9EFE6B; Thu, 8 Oct 2009 19:43:33 +0200 (CEST) X-GNU-Emacs-Mailer: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Thu, 08 Oct 2009 14:07:16 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:31789 Archived-At: What is the best way to implement --script? Let me discuss some possibilities: 1. The current implementation. It consists of the lines if (c == '!') { /* #! appears at the beginning of an executable file. Skip the first line. */ while (c != '\n' && c >= 0) c = READCHAR; goto retry; } in function read1 in lread.c. This is appealing by its brevity. However it has the disadvantage that the basic read function has a *general* feature in order to get --script and the "#!"-syntax working. Further it leads to the bug originally posted: Execution of an empty script file like ===File ~/x.el============================================== #!/home/rost/build/cvs/emacs/src/emacs --script ============================================================ yields an "End of file during parsing" error and returns with positive exit status. 2. One may think of handling --script by first removing a first #!-line before passing the file to load. This seems to be very hard to implement because the load routine is complicated (switching back and forth between C and Elisp functions). Besides this practical problem, there is the following disadvantage: In some circumstances one may want to load a script file directly, as in emacs -batch ... -l ~/x.el ... Moreover, when editing the file one may want to test it with eval-buffer. 3. This leaves the possibility to handle #!-lines when running eval-region. It should skip a #!-line at the beginning of the region. It could skip any #!-line in the region, which is what read1 does right now, but I see no necessity for that. This would be implemented by my two previous patches Of course making a change in readevalloop/read1 needs a careful check, maybe by several people. However, the patch is a very "local" one around the variable unread_char and there are only a few places where unread_char appears, so checking the patch is not too much work. Moreover, if something would be wrong with the change, very likely emacs would not even compile as many files are loaded during the build process.