unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Marius Vollmer <mvo@zagadka.ping.de>
Subject: Re: Sesquicolon -- Note: Not a Bug
Date: 25 Aug 2002 12:01:01 +0200	[thread overview]
Message-ID: <87bs7r9s0y.fsf@zagadka.ping.de> (raw)
In-Reply-To: <20020825053748.GA2511@gnu.org>

Miles Bader <miles@gnu.org> 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

  reply	other threads:[~2002-08-25 10:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.GSO.4.10.10208230008380.5847-100000@asuwlink.uwyo.edu>
2002-08-25  5:26 ` Sesquicolon -- Note: Not a Bug Richard Stallman
2002-08-25  5:37   ` Miles Bader
2002-08-25 10:01     ` Marius Vollmer [this message]
2002-08-26 12:53       ` Richard Stallman
2002-08-26 21:19         ` Marius Vollmer
2002-08-26 22:08           ` Stefan Monnier
2002-08-26  0:36     ` Richard Stallman
2002-08-26  1:53       ` Miles Bader
2002-08-26 21:51         ` Richard Stallman
2002-08-26 22:15           ` Stefan Monnier
2002-08-27  9:28             ` Kim F. Storm
2002-08-31 12:17           ` Pavel Janík
2002-09-01 13:15             ` Richard Stallman
2002-09-04 17:33               ` Pavel Janík
2002-08-25 18:52   ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87bs7r9s0y.fsf@zagadka.ping.de \
    --to=mvo@zagadka.ping.de \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).