From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.emacs.devel Subject: Re: Sesquicolon -- Note: Not a Bug Date: 25 Aug 2002 12:01:01 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <87bs7r9s0y.fsf@zagadka.ping.de> References: <200208250526.g7P5Q3F11930@wijiji.santafe.edu> <20020825053748.GA2511@gnu.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1030269722 3258 127.0.0.1 (25 Aug 2002 10:02:02 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 25 Aug 2002 10:02:02 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17iuDY-0000qR-00 for ; Sun, 25 Aug 2002 12:02:00 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17iuhq-0007i8-00 for ; Sun, 25 Aug 2002 12:33:18 +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 17iuEi-0008Am-00; Sun, 25 Aug 2002 06:03:12 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17iuCg-000820-00 for emacs-devel@gnu.org; Sun, 25 Aug 2002 06:01:06 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17iuCe-00081f-00 for emacs-devel@gnu.org; Sun, 25 Aug 2002 06:01:05 -0400 Original-Received: from dialin.speedway42.dip197.dokom.de ([195.138.42.197] helo=zagadka.ping.de) by monty-python.gnu.org with smtp (Exim 4.10) id 17iuCd-00081V-00 for emacs-devel@gnu.org; Sun, 25 Aug 2002 06:01:03 -0400 Original-Received: (qmail 28747 invoked by uid 1000); 25 Aug 2002 10:01:01 -0000 Original-To: emacs-devel@gnu.org In-Reply-To: <20020825053748.GA2511@gnu.org> Original-Lines: 71 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 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:6869 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:6869 Miles Bader writes: > On Sat, Aug 24, 2002 at 11:26:03PM -0600, Richard Stallman wrote: > > I wonder if there is a way we could change Emacs so that it could run > > properly with #!. Here's an idea that might work: suppose that when > > Emacs's stdin is a file, but there is no -batch option, it > > automatically starts in batch mode and loads $0. WIth that change, > > maybe #!/usr/bin/emacs could work. > > What's wrong with just adding a single option that has the necessary > semantics? Guile uses "\" as a 'meta-switch'. It causes Guile to interpret the second line of the script as options. (The meta-switch originally came from Scsh, I think.) From the Guile manual: Thus, consider a script named `/u/jimb/ekko' which starts like this: #!/usr/local/bin/guile \ -e main -s !# (define (main args) (map (lambda (arg) (display arg) (display " ")) (cdr args)) (newline)) Suppose a user invokes this script as follows: $ /u/jimb/ekko a b c Here's what happens: * the operating system recognizes the `#!' token at the top of the file, and rewrites the command line to: /usr/local/bin/guile \ /u/jimb/ekko a b c This is the usual behavior, prescribed by POSIX. * When Guile sees the first two arguments, `\ /u/jimb/ekko', it opens `/u/jimb/ekko', parses the three arguments `-e', `main', and `-s' from it, and substitutes them for the `\' switch. Thus, Guile's command line now reads: /usr/local/bin/guile -e main -s /u/jimb/ekko a b c * Guile then processes these switches: it loads `/u/jimb/ekko' as a file of Scheme code (treating the first three lines as a comment), and then performs the application `(main "/u/jimb/ekko" "a" "b" "c")'. When Guile sees the meta switch `\', it parses command-line argument from the script file according to the following rules: * Each space character terminates an argument. This means that two spaces in a row introduce an argument `""'. * The tab character is not permitted (unless you quote it with the backslash character, as described below), to avoid confusion. * The newline character terminates the sequence of arguments, and will also terminate a final non-empty argument. (However, a newline following a space will not introduce a final empty-string argument; it only terminates the argument list.) * The backslash character is the escape character. It escapes backslash, space, tab, and newline. The ANSI C escape sequences like `\n' and `\t' are also supported. These produce argument constituents; the two-character combination `\n' doesn't act like a terminating newline. The escape sequence `\NNN' for exactly three octal digits reads as the character whose ASCII code is NNN. As above, characters produced this way are argument constituents. Backslash followed by other characters is not allowed. -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405