GNU bug report logs - #4399
simple way to identify top-level --script file

Previous Next

Package: emacs;

Reported by: Tom Tromey <tromey <at> redhat.com>

Date: Fri, 11 Sep 2009 02:15:04 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4399 in the body.
You can then email your comments to 4399 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 11 Sep 2009 02:15:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tom Tromey <tromey <at> redhat.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 11 Sep 2009 02:15:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Tom Tromey <tromey <at> redhat.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; let a file know it was run with --script 
Date: Thu, 10 Sep 2009 20:06:39 -0600
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs <at> gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


On occasion it would be convenient to have a .el file which could check
whether it was invoked with --script.  (Python can do this, it is quite
handy there.)

I don't think there is a way to do this currently.


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/23.1/etc/DEBUG for instructions.


In GNU Emacs 23.1.1 (i386-redhat-linux-gnu, GTK+ Version 2.16.5)
 of 2009-08-26 on x86-2.fedora.phx.redhat.com
Windowing system distributor `The X.Org Foundation', version 11.0.10601901
configured using `configure  '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--target=i586-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'target_alias=i586-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  gnus-agent-mode: t
  shell-dirtrack-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-spelling-mode: t
  erc-truncate-mode: t
  diff-auto-refine-mode: t
  gnus-undo-mode: t
  erc-status-mode: t
  erc-services-mode: t
  erc-networks-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
q SPC 5 0 <return> M-> SPC Q y C-n C-n C-SPC C-u E 
SPC C-u E q C-z o <f10> <f10> C-z o C-r o t h e r C-a 
SPC 5 0 <return> M-> C-u C-u C-p C-u C-n p = C-u E 
E E E E E S-SPC E S-SPC E S-SPC E S-SPC E C-u C-p C-n 
M S-SPC M S-SPC M S-SPC q s C-u C-u C-n p p SPC 5 0 
<return> M-> q SPC M-> q C-s a r c C-a C-s f r C-a 
SPC 5 0 <return> M-> Q y s ESC [ > 1 ; 2 0 0 5 ; 0 
c C-x b * G TAB RET 1 g n n SPC ESC > Q y C-r o t h 
e r C-a SPC 5 0 RET ESC > C-u C-p C-p p C-u RET RET 
RET RET RET C-u RET M SPC n M SPC SPC E E SPC SPC SPC 
E = C-l C-a ESC v ESC v ESC v q s ESC [ 2 1 ~ ESC [ 
2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 
~ C-v C-l p p p SPC E q n n SPC ESC > C-p C-p E E q 
C-l C-u C-n C-u C-n C-u C-n C-l n SPC 5 RET Q y n n 
n SPC 5 0 RET ESC > Q y p SPC 5 0 RET ESC > Q y s ESC 
v ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC [ 2 1 ~ ESC 
[ 2 1 ~ ESC x r e p o r t - e m TAB b TAB RET

Recent messages:
Retrieving newsgroup: nnml:mail.cygnus...
Fetching headers for nnml:mail.cygnus...done
Generating summary...done
Mark set
Discard changes to this group and exit? (y or n) 
(No changes need to be saved)
Saving /home/tromey/.newsrc.eld...
Saving file /home/tromey/.newsrc.eld...
Wrote /home/tromey/.newsrc.eld
Saving /home/tromey/.newsrc.eld...done

Tom




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 11 Sep 2009 04:05:04 GMT) Full text and rfc822 format available.

Message #8 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Tom Tromey <tromey <at> redhat.com>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Thu, 10 Sep 2009 23:58:47 -0400
Tom Tromey wrote:

> On occasion it would be convenient to have a .el file which could check
> whether it was invoked with --script.

You can check for a non-nil value of `noninteractive'. Or do you need
to distinguish --batch from --script for some reason?



bug closed, send any further explanations to Tom Tromey <tromey <at> redhat.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 17 Sep 2009 20:55:09 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 18 Sep 2009 17:40:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tom Tromey <tromey <at> redhat.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 18 Sep 2009 17:40:05 GMT) Full text and rfc822 format available.

Message #15 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Tom Tromey <tromey <at> redhat.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 11:34:50 -0600
>>>>> "GM" == Glenn Morris <rgm <at> gnu.org> writes:

Sorry for the delay in my reply.

>> On occasion it would be convenient to have a .el file which could check
>> whether it was invoked with --script.

GM> You can check for a non-nil value of `noninteractive'. Or do you need
GM> to distinguish --batch from --script for some reason?

I was hoping for something like the python idiom:

    if __name__ == "__main__":

... this lets a file determine if it was invoked "as the main program".

My specific use was for tests: I want "emacs --script test.el" to run
the tests, but I want to be able to load the file just to get the defuns
without running the test suite.

Tom



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 18 Sep 2009 18:10:14 GMT) Full text and rfc822 format available.

Message #18 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Tom Tromey <tromey <at> redhat.com>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 14:04:44 -0400
Tom Tromey wrote:

> My specific use was for tests: I want "emacs --script test.el" to run
> the tests, but I want to be able to load the file just to get the defuns
> without running the test suite.

It sounds like noninteractive will work fine (you could perhaps check
command-line-args if you want finer control)? Or use the traditional:

emacs -batch -l ./test.el -f batch-run-tests



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 18 Sep 2009 19:05:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tom Tromey <tromey <at> redhat.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Fri, 18 Sep 2009 19:05:06 GMT) Full text and rfc822 format available.

Message #23 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Tom Tromey <tromey <at> redhat.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 12:56:59 -0600
>>>>> "GM" == Glenn Morris <rgm <at> gnu.org> writes:

GM> It sounds like noninteractive will work fine (you could perhaps check
GM> command-line-args if you want finer control)? Or use the traditional:

I don't think that has the same effect if you load multiple such files.
I only want the "main" one to eval the code.

GM> emacs -batch -l ./test.el -f batch-run-tests

This won't work if you want to use #! to start a script.

I guess I can work around this by writing a new .el that just loads
things and evals something.

Tom



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Fri, 18 Sep 2009 19:05:08 GMT) Full text and rfc822 format available.

Message #26 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Tom Tromey <tromey <at> redhat.com>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 15:00:38 -0400
Tom Tromey wrote:

>>>>>> "GM" == Glenn Morris <rgm <at> gnu.org> writes:
>
> GM> It sounds like noninteractive will work fine (you could perhaps check
> GM> command-line-args if you want finer control)?
>
> I don't think that has the same effect if you load multiple such files.
> I only want the "main" one to eval the code.

That's what I was suggesting checking command-line-args for.

If you still need some extra functionality, we can leave reopen this
as a wishlist.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Sat, 19 Sep 2009 01:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tom Tromey <tromey <at> redhat.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 19 Sep 2009 01:20:05 GMT) Full text and rfc822 format available.

Message #31 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Tom Tromey <tromey <at> redhat.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 19:11:04 -0600
GM> That's what I was suggesting checking command-line-args for.

Ah, now I get it.
I guess this will work as long as I don't mind hard-coding in the file's
name.  Unless there's a way to also get this?

thanks,
Tom



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4399; Package emacs. (Sat, 19 Sep 2009 03:25:05 GMT) Full text and rfc822 format available.

Message #34 received at 4399 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Tom Tromey <tromey <at> redhat.com>
Cc: 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: 23.1; let a file know it was run with --script
Date: Fri, 18 Sep 2009 23:19:09 -0400
reopen 4399
severity 4399 wishlist
retitle 4399 simple way to identify top-level --script file
stop

Tom Tromey wrote:

> I guess this will work as long as I don't mind hard-coding in the file's
> name.  Unless there's a way to also get this?

On reflection, it seems a pretty poor solution, so I'll reopen this as
a wishlist.

Summary:

When using --script, it would be nice if there was a simple way for
the file so loaded to identify itself as the "main file", distinct
from any libraries it might require.


(I'd probably just use a hack like:

#!/bin/sh

exec emacs -batch -l test.el -f batch-run-test

but I suppose this is against the spirit of --script)



Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Sat, 19 Sep 2009 03:25:07 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sat, 19 Sep 2009 03:25:07 GMT) Full text and rfc822 format available.

Changed bug title to 'simple way to identify top-level --script file' from '23.1; let a file know it was run with --script ' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sat, 19 Sep 2009 03:25:07 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4399; Package emacs. (Mon, 07 Feb 2022 00:55:02 GMT) Full text and rfc822 format available.

Message #43 received at 4399 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tom Tromey <tromey <at> redhat.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 4399 <at> debbugs.gnu.org
Subject: Re: bug#4399: simple way to identify top-level --script file
Date: Mon, 07 Feb 2022 01:54:48 +0100
Tom Tromey <tromey <at> redhat.com> writes:

> I was hoping for something like the python idiom:
>
>     if __name__ == "__main__":
>
> ... this lets a file determine if it was invoked "as the main program".
>
> My specific use was for tests: I want "emacs --script test.el" to run
> the tests, but I want to be able to load the file just to get the defuns
> without running the test suite.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

In my opinion, I think it would be too niche to add a special mechanism
for this.  You can use --eval '(setq something-to-react-to t)' --script
... if you want to have different things happening in this case.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Feb 2022 00:56:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 4399 <at> debbugs.gnu.org and Tom Tromey <tromey <at> redhat.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Feb 2022 00:56:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 07 Mar 2022 12:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 22 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.