* Re: Sesquicolon -- Note: Not a Bug [not found] <Pine.GSO.4.10.10208230008380.5847-100000@asuwlink.uwyo.edu> @ 2002-08-25 5:26 ` Richard Stallman 2002-08-25 5:37 ` Miles Bader 2002-08-25 18:52 ` Stefan Monnier 0 siblings, 2 replies; 15+ messages in thread From: Richard Stallman @ 2002-08-25 5:26 UTC (permalink / raw) Cc: emacs-devel For the languages other than Emacs Lisp, we use the shebang, "#!", as the first two characters of our scripts; but since Emacs requires more than two arguments to load and run a script in batch mode, I use the sesquicolon, ":;", for Emacs. ;; would work if you feed the script manually as input to Bash. However, the special thing about #! is that exec recognizes it. exec won't recognize ;;. 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 do people think? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 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 2002-08-26 0:36 ` Richard Stallman 2002-08-25 18:52 ` Stefan Monnier 1 sibling, 2 replies; 15+ messages in thread From: Miles Bader @ 2002-08-25 5:37 UTC (permalink / raw) Cc: polymath, emacs-devel 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? Special casing on stdin-is-a-file seems wrong because someone might want to runan elisp-script from a terminal. -Miles -- P.S. All information contained in the above letter is false, for reasons of military security. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-25 5:37 ` Miles Bader @ 2002-08-25 10:01 ` Marius Vollmer 2002-08-26 12:53 ` Richard Stallman 2002-08-26 0:36 ` Richard Stallman 1 sibling, 1 reply; 15+ messages in thread From: Marius Vollmer @ 2002-08-25 10:01 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-25 10:01 ` Marius Vollmer @ 2002-08-26 12:53 ` Richard Stallman 2002-08-26 21:19 ` Marius Vollmer 0 siblings, 1 reply; 15+ messages in thread From: Richard Stallman @ 2002-08-26 12:53 UTC (permalink / raw) Cc: emacs-devel The meta-switch idea is clever, and we might as well add that feature to Emacs. However, we would still want to give Emacs a single convenient option for doing this sort of job; it should not require lots of complicated options. It was suggested that just -batch with no other arguments could do this. That would be a special case exception, but I guess it is harmless since `emacs -batch' right now just exits and is useless. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 12:53 ` Richard Stallman @ 2002-08-26 21:19 ` Marius Vollmer 2002-08-26 22:08 ` Stefan Monnier 0 siblings, 1 reply; 15+ messages in thread From: Marius Vollmer @ 2002-08-26 21:19 UTC (permalink / raw) Cc: emacs-devel Richard Stallman <rms@gnu.org> writes: > It was suggested that just -batch with no other arguments > could do this. The '#!' mechanism would not result in -batch with no other arguments. The file name of the script is added to the end of the command line. Why do you need to reuse the "-batch" name? Can't it just be a new name, like "--batch-script"? -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 21:19 ` Marius Vollmer @ 2002-08-26 22:08 ` Stefan Monnier 0 siblings, 0 replies; 15+ messages in thread From: Stefan Monnier @ 2002-08-26 22:08 UTC (permalink / raw) Cc: rms, emacs-devel > Richard Stallman <rms@gnu.org> writes: > > > It was suggested that just -batch with no other arguments > > could do this. > > The '#!' mechanism would not result in -batch with no other arguments. > The file name of the script is added to the end of the command line. Sure, that's what was meant. `emacs -batch <file> would execute the file in batch mode. > Why do you need to reuse the "-batch" name? Why not ? > Can't it just be a new name, like "--batch-script"? We could do that as well. Note that some systems have a limit of 32 chars past which the #! things are ignored: your suggestion takes 14 chars, which doesn't leave much to the "path to emacs plus space". The reuse of --batch (and thus -b as well) is preferable from that point of view. But of course, we could also use -B or whatever else we may fancy. Stefan ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-25 5:37 ` Miles Bader 2002-08-25 10:01 ` Marius Vollmer @ 2002-08-26 0:36 ` Richard Stallman 2002-08-26 1:53 ` Miles Bader 1 sibling, 1 reply; 15+ messages in thread From: Richard Stallman @ 2002-08-26 0:36 UTC (permalink / raw) Cc: polymath, emacs-devel What's wrong with just adding a single option that has the necessary semantics? Would that do the job? I don't know the precise rules of what #! can do. If that would do the job, it is a fine solution. We could call it --script. Would you like to implement it? Special casing on stdin-is-a-file seems wrong because someone might want to runan elisp-script from a terminal. It is slightly inelegant to special case it, but there should be other ways to do this -- which isn't a very useful thing to do. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 0:36 ` Richard Stallman @ 2002-08-26 1:53 ` Miles Bader 2002-08-26 21:51 ` Richard Stallman 0 siblings, 1 reply; 15+ messages in thread From: Miles Bader @ 2002-08-26 1:53 UTC (permalink / raw) Cc: polymath, emacs-devel Richard Stallman <rms@gnu.org> writes: > What's wrong with just adding a single option that has the > necessary semantics? > > Would that do the job? I don't know the precise rules of what #! can > do. If that would do the job, it is a fine solution. We could call > it --script. To the best of my knowledge, you're allowed exactly one option (which will go before the filename). I think Stefan's suggestion to special-case --batch to load the following filename argument when there's no other options seems sensible (it seems very unlikely to conflict with current usage, since surely everyone using --batch now also uses -l, -f, or --exec). > Special casing on stdin-is-a-file seems wrong because someone > might want to runan elisp-script from a terminal. > > It is slightly inelegant to special case it, but there should be other > ways to do this -- which isn't a very useful thing to do. I don't know... it sounds very useful to me -- elisp is a fine language for writing interactive scripts, even if they don't use the full-screen redisplay. -Miles -- `The suburb is an obsolete and contradictory form of human settlement' ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 1:53 ` Miles Bader @ 2002-08-26 21:51 ` Richard Stallman 2002-08-26 22:15 ` Stefan Monnier 2002-08-31 12:17 ` Pavel Janík 0 siblings, 2 replies; 15+ messages in thread From: Richard Stallman @ 2002-08-26 21:51 UTC (permalink / raw) Cc: polymath, emacs-devel > Would that do the job? I don't know the precise rules of what #! can > do. If that would do the job, it is a fine solution. We could call > it --script. To the best of my knowledge, you're allowed exactly one option (which will go before the filename). Are you saying that Emacs would be called with two arguments, the option and a file name? If so, we should not use -batch for this. To special-case the combination of --batch and a file name is a double-level kludge, because each of those arguments normally has a different and incompatible meaning. For the combination of the two to do something special is too inconsistent. Let's make a new option --script for this purpose. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 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 1 sibling, 1 reply; 15+ messages in thread From: Stefan Monnier @ 2002-08-26 22:15 UTC (permalink / raw) Cc: miles, polymath, emacs-devel > > Would that do the job? I don't know the precise rules of what #! can > > do. If that would do the job, it is a fine solution. We could call > > it --script. > > To the best of my knowledge, you're allowed exactly one option (which > will go before the filename). > > Are you saying that Emacs would be called with two arguments, > the option and a file name? Yes, that's exactly what I suggested. To make `emacs -batch <file>' behave like `emacs -batch --load <file>'. > If so, we should not use -batch for this. To bad. It seemed like a very natural extension of `-batch' since `emacs -batch <file>' is generally useless anyway (it just visits <file> and exits). If we want to use something else, it would be good to provide a shorthand for the cases where the OS only takes the first 32chars of the #! line into account. Stefan ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 22:15 ` Stefan Monnier @ 2002-08-27 9:28 ` Kim F. Storm 0 siblings, 0 replies; 15+ messages in thread From: Kim F. Storm @ 2002-08-27 9:28 UTC (permalink / raw) Cc: Richard Stallman, miles, polymath, emacs-devel "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes: > To make `emacs -batch <file>' behave like `emacs -batch --load <file>'. FWIW, this seems very natural to me too. > > > If so, we should not use -batch for this. > > To bad. It seemed like a very natural extension of `-batch' > since `emacs -batch <file>' is generally useless anyway (it > just visits <file> and exits). Exactly. -- Kim F. Storm <storm@cua.dk> http://www.cua.dk ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-26 21:51 ` Richard Stallman 2002-08-26 22:15 ` Stefan Monnier @ 2002-08-31 12:17 ` Pavel Janík 2002-09-01 13:15 ` Richard Stallman 1 sibling, 1 reply; 15+ messages in thread From: Pavel Janík @ 2002-08-31 12:17 UTC (permalink / raw) Cc: miles, polymath, emacs-devel From: Richard Stallman <rms@gnu.org> Date: Mon, 26 Aug 2002 15:51:56 -0600 (MDT) > Let's make a new option --script for this purpose. The current implementation is not enough: pavel@SnowWhite:/tmp> cat /tmp/qq #!/usr/bin/emacs --script (message "The date is %s" (current-time-string)) pavel@SnowWhite:/tmp> /tmp/qq Invalid read syntax: "#" When called with --script, emacs should ignore #! and the rest of the line (I do not know if that line could continue on the following lines too). -- Pavel Janík Yeah, but you have to be masochist enough to use TeX! -- Stephane Boucher in gnu.emacs.help ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-31 12:17 ` Pavel Janík @ 2002-09-01 13:15 ` Richard Stallman 2002-09-04 17:33 ` Pavel Janík 0 siblings, 1 reply; 15+ messages in thread From: Richard Stallman @ 2002-09-01 13:15 UTC (permalink / raw) Cc: miles, polymath, emacs-devel The current implementation is not enough: pavel@SnowWhite:/tmp> cat /tmp/qq #!/usr/bin/emacs --script (message "The date is %s" (current-time-string)) pavel@SnowWhite:/tmp> /tmp/qq Invalid read syntax: "#" Does this fix it? *** lread.c.~1.296.~ Fri Aug 23 23:14:22 2002 --- lread.c Sat Aug 31 19:38:44 2002 *************** *** 2098,2103 **** --- 2098,2111 ---- goto retry; } + if (c == '!') + { + /* #! appears at the beginning of an executable file. + Skip the first line. */ + while (c != '\n') + c = READCHAR; + goto retry; + } if (c == '$') return Vload_file_name; if (c == '\'') ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-09-01 13:15 ` Richard Stallman @ 2002-09-04 17:33 ` Pavel Janík 0 siblings, 0 replies; 15+ messages in thread From: Pavel Janík @ 2002-09-04 17:33 UTC (permalink / raw) Cc: miles, polymath, emacs-devel From: Richard Stallman <rms@gnu.org> Date: Sun, 01 Sep 2002 09:15:00 -0400 > pavel@SnowWhite:/tmp> /tmp/qq > Invalid read syntax: "#" > > Does this fix it? > > *** lread.c.~1.296.~ Fri Aug 23 23:14:22 2002 > --- lread.c Sat Aug 31 19:38:44 2002 Yes, thank you. -- Pavel Janík How about BogoDegrees? -- Bill Pringlemeir in linux-kernel about using Kelvins ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Sesquicolon -- Note: Not a Bug 2002-08-25 5:26 ` Sesquicolon -- Note: Not a Bug Richard Stallman 2002-08-25 5:37 ` Miles Bader @ 2002-08-25 18:52 ` Stefan Monnier 1 sibling, 0 replies; 15+ messages in thread From: Stefan Monnier @ 2002-08-25 18:52 UTC (permalink / raw) Cc: polymath, emacs-devel > For the languages other than Emacs Lisp, we use the shebang, "#!", as > the first two characters of our scripts; but since Emacs requires more > than two arguments to load and run a script in batch mode, I use the > sesquicolon, ":;", for Emacs. > > ;; would work if you feed the script manually as input to Bash. > However, the special thing about #! is that exec recognizes it. > exec won't recognize ;;. > > 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 do people think? I don't see what stdin has to do with it. A script as shown above will simply cause the kernel to run `/usr/bin/emacs /the/script/file/name' with the same old stdin, stdout, stderr, ... so Emacs will simply load the script as a file to be edited. If we don't want to add a new parameter, we could simply recognize emacs -batch <file> as a shorthand for emacs -batch --load <file> since (after all) just `emacs -batch <file>' doesn't make much sense except for the very rare case where we want to execute what's in the `local variables' section of the file. Stefan ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2002-09-04 17:33 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [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 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
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).