comparison src/lread.c @ 4448:fd8a9a4d81d9

Support #!, to allow XEmacs to be called as a script interpreter. ChangeLog addition: 2008-01-20 Aidan Kehoe <kehoea@parhasard.net> * Makefile.in.in (SHEBANG_PROGNAME): New variable; a symbol link to the XEmacs binary to tell it it should read a script from stdin. * configure.ac (XE_EXPAND_VARIABLE): Set SHEBANG_PROGNAME. * configure: Regenerate. src/ChangeLog addition: 2008-01-20 Aidan Kehoe <kehoea@parhasard.net> * config.h.in: Add SHEBANG_PROGNAME. * emacs.c (main_1): If we've been called using SHEBANG_PROGNAME, rewrite our arguments to add a --script argument. Also, handle the --script argument by setting noninteractive and vanilla. * lread.c (Fload_internal): If the first two characters of a file are #!, replace them with ;! before they get to the Lisp reader. lisp/ChangeLog addition: 2008-01-20 Aidan Kehoe <kehoea@parhasard.net> * startup.el (command-line-do-script): New. (command-switch-alist): Use command-line-do-script. New argument, compatible with GNU; --script or -script says "treat the following argument as a file to load in batch mode". man/ChangeLog addition: 2008-01-20 Aidan Kehoe <kehoea@parhasard.net> * xemacs/cmdargs.texi (Command Switches): Describe --script, -script.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 20 Jan 2008 19:53:54 +0100
parents d9eb5ea14f65
children ac6231e0c1df
comparison
equal deleted inserted replaced
4408:8bbabcab2c42 4448:fd8a9a4d81d9
741 internal_bind_lisp_object (&Vload_file_name, found); 741 internal_bind_lisp_object (&Vload_file_name, found);
742 #ifdef I18N3 742 #ifdef I18N3
743 /* set it to nil; a call to #'domain will set it. */ 743 /* set it to nil; a call to #'domain will set it. */
744 internal_bind_lisp_object (&Vfile_domain, Qnil); 744 internal_bind_lisp_object (&Vfile_domain, Qnil);
745 #endif 745 #endif
746
747 /* Is there a #!? If so, read it, and unread ;!.
748
749 GNU implement this by treating any #! anywhere in the source text as
750 commenting out the whole line. */
751 {
752 char shebangp[2];
753 int num_read;
754
755 num_read = Lstream_read (XLSTREAM (lispstream), shebangp,
756 sizeof(shebangp));
757 if (sizeof(shebangp) == num_read
758 && 0 == strncmp("#!", shebangp, sizeof(shebangp)))
759 {
760 shebangp[0] = ';';
761 }
762
763 Lstream_unread (XLSTREAM (lispstream), shebangp, num_read);
764 }
746 765
747 /* Now determine what sort of ELC file we're reading in. */ 766 /* Now determine what sort of ELC file we're reading in. */
748 internal_bind_int (&load_byte_code_version, load_byte_code_version); 767 internal_bind_int (&load_byte_code_version, load_byte_code_version);
749 if (reading_elc) 768 if (reading_elc)
750 { 769 {