all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Markus Rost <rost@math.uni-bielefeld.de>
To: 4616@emacsbugs.donarmstrong.com
Subject: bug#4616: 23.1.50; empty script files
Date: Thu,  8 Oct 2009 19:43:32 +0200 (CEST)	[thread overview]
Message-ID: <20091008174333.11AC9EFE6B@sonic02.math.uni-bielefeld.de> (raw)

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

   <URL:http://lists.gnu.org/archive/html/bug-gnu-emacs/2009-10/msg00082.html>
   <URL:http://lists.gnu.org/archive/html/bug-gnu-emacs/2009-10/msg00124.html>

   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.





             reply	other threads:[~2009-10-08 17:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-08 17:43 Markus Rost [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-02 14:01 bug#4616: 23.1.50; empty script files Markus Rost
     [not found] ` <m2k4zbmvao.fsf@whitebox.home>
2009-10-05  3:11   ` Markus Rost
2009-10-06 15:19   ` Markus Rost
     [not found]   ` <20091004150617.5367DEFB40@sonic02.math.uni-bielefeld.de>
2020-08-25 13:58     ` Lars Ingebrigtsen
2020-08-25 15:44       ` Markus Rost
2020-08-26  9:53         ` Lars Ingebrigtsen
2022-02-10 12:45           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091008174333.11AC9EFE6B@sonic02.math.uni-bielefeld.de \
    --to=rost@math.uni-bielefeld.de \
    --cc=4616@emacsbugs.donarmstrong.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.