GNU bug report logs -
#25671
Feature request: emacs -Q --script as a single binary
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25671 in the body.
You can then email your comments to 25671 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Thu, 09 Feb 2017 21:16:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Clément Pit--Claudel <clement.pitclaudel <at> live.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 09 Feb 2017 21:16:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi bug-gnu-emacs,
Since version 22 Emacs lets scripts begin with a shebang line:
#!/usr/bin/emacs --script
;; Some ELisp code here
This breaks if Emacs isn't installed in /usr/bin, though. Thus, one would want to write this:
#!/usr/bin/env emacs --script
;; Some ELisp code here
But this doesn't work (env doesn't split its arguments), and it also breaks even if one is happy with hardcoding /usr/bin/emacs but tries to pass more than one argument (think -Q and --script). Thus one writes this:
#!/bin/sh
":"; exec emacs -Q --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
(See http://stackoverflow.com/questions/6238331/emacs-shell-scripts-how-to-put-initial-options-into-the-script/6259330#6259330)
This isn't pretty. Could we set up emacs to assume --script and possibly -Q when started as "elisp", or "emacs-script", or some other name (that is, could we make it so that invoking emacs with argv[0] = ".../elisp" starts emacs -Q --script)? (And ideally Emacs would ignore all options after the script's name, to let the script itself process them).
Thanks!
Clément.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Thu, 09 Feb 2017 21:28:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 25671 <at> debbugs.gnu.org (full text, mbox):
This seems like a duplicate of https://debbugs.gnu.org/20682 .
(IMO a big, unwieldy text editor that is never going to be a sensible
alternative to bash, perl, python etc for scripting.)
Merged 20682 25671.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 09 Feb 2017 21:30:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Thu, 09 Feb 2017 21:33:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 25671 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2017-02-09 16:27, Glenn Morris wrote:
> This seems like a duplicate of https://debbugs.gnu.org/20682 .
>
> (IMO a big, unwieldy text editor that is never going to be a sensible
> alternative to bash, perl, python etc for scripting.)
Partly; thanks for the pointer! That thread still assumes that you can pass an argument to Emacs, though, which isn't always the case (e.g. if you want to use /usr/bin/env).
Clément.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 07:38:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 25671 <at> debbugs.gnu.org (full text, mbox):
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Thu, 9 Feb 2017 16:14:41 -0500
>
> Could we set up emacs to assume --script and possibly -Q when started as "elisp", or "emacs-script", or some other name (that is, could we make it so that invoking emacs with argv[0] = ".../elisp" starts emacs -Q --script)? (And ideally Emacs would ignore all options after the script's name, to let the script itself process them).
I believe changing the program behavior depending on how it was named
in the command that invoked it is against GNU coding standards.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 14:18:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 25671 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2017-02-10 02:37, Eli Zaretskii wrote:
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Thu, 9 Feb 2017 16:14:41 -0500
>>
>> Could we set up emacs to assume --script and possibly -Q when started as "elisp", or "emacs-script", or some other name (that is, could we make it so that invoking emacs with argv[0] = ".../elisp" starts emacs -Q --script)? (And ideally Emacs would ignore all options after the script's name, to let the script itself process them).
>
> I believe changing the program behavior depending on how it was named
> in the command that invoked it is against GNU coding standards.
What about providing elisp or emacs-script as a separate binary?
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 15:03:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 25671 <at> debbugs.gnu.org (full text, mbox):
> Cc: 25671 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Fri, 10 Feb 2017 09:17:00 -0500
>
> > I believe changing the program behavior depending on how it was named
> > in the command that invoked it is against GNU coding standards.
>
> What about providing elisp or emacs-script as a separate binary?
What about it?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 16:47:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 25671 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2017-02-10 10:02, Eli Zaretskii wrote:
>> Cc: 25671 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Fri, 10 Feb 2017 09:17:00 -0500
>>
>>> I believe changing the program behavior depending on how it was named
>>> in the command that invoked it is against GNU coding standards.
>>
>> What about providing elisp or emacs-script as a separate binary?
>
> What about it?
Would that be OK? Could it work? I thought it would make implementation simpler to just make the emacs binary ct differently based on how its invoked, but if that's not OK then could we distribute a separate "elisp" or "emacs-script" binary that can be used in a shebang line?
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 16:59:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 25671 <at> debbugs.gnu.org (full text, mbox):
> Cc: 25671 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Fri, 10 Feb 2017 11:45:55 -0500
>
> >>> I believe changing the program behavior depending on how it was named
> >>> in the command that invoked it is against GNU coding standards.
> >>
> >> What about providing elisp or emacs-script as a separate binary?
> >
> > What about it?
>
> Would that be OK? Could it work?
Yes, it will. Although distributing two large binaries might be
overkill. (All that just to make shell scripts slightly simpler?)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 17:33:01 GMT)
Full text and
rfc822 format available.
Message #31 received at 25671 <at> debbugs.gnu.org (full text, mbox):
Clément Pit--Claudel wrote:
>>> What about providing elisp or emacs-script as a separate binary?
>>
>> What about it?
>
> Would that be OK?
I would not like installing Emacs to pollute my PATH with trivial things
like that. In https://debbugs.gnu.org/20682#11 I mentioned a
standard solution for this issue as used by perl, ruby, etc;
namely a -x switch.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 20:22:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 25671 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2017-02-10 12:32, Glenn Morris wrote:
> Clément Pit--Claudel wrote:
>
>>>> What about providing elisp or emacs-script as a separate binary?
>>>
>>> What about it?
>>
>> Would that be OK?
>
> I would not like installing Emacs to pollute my PATH with trivial things
> like that. In https://debbugs.gnu.org/20682#11 I mentioned a
> standard solution for this issue as used by perl, ruby, etc;
> namely a -x switch.
Can you explain how that works wrt the problem I mentioned in my original post? "#!/usr/bin/env emacs -x" doesn't work, does it?
Clément
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 10 Feb 2017 20:22:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 25671 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2017-02-10 11:58, Eli Zaretskii wrote:
>> Cc: 25671 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Fri, 10 Feb 2017 11:45:55 -0500
>>
>>>>> I believe changing the program behavior depending on how it was named
>>>>> in the command that invoked it is against GNU coding standards.
>>>>
>>>> What about providing elisp or emacs-script as a separate binary?
>>>
>>> What about it?
>>
>> Would that be OK? Could it work?
>
> Yes, it will. Although distributing two large binaries might be
> overkill. (All that just to make shell scripts slightly simpler?)
Right; that's why I thought the "two possible names for the same binary" approach was nice :/
It would make it possible to run elisp command line programs in Windows without a batch script wrapper, and it would make these scripts nicer in GNU/Linux and macOS. But arguably that's still a limited benefit. If there's no way to reuse the Emacs binary (that is, if there's no way to make "elisp" just be a wrapper around "emacs"), then I think we should close this issue.
Cheers,
Clément.
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Mon, 18 Apr 2022 11:02:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 25671 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
>> OTOH I'd be happy to see a new argument that lets you provide various
>> args as one. E.g. "emacs --args=-Q,--script" which would be more
>> generally useful to deal with the limit of only one arg in shebang.
>> Given the size limit of shebang lines, we'd also want this extra arg to
>> be shortish.
>>
>> An alternative would be to combine --args and --script, so you could
>> say "emacs --script=-Q" to get what you're asking for.
>
> Apparently it's somewhat conventional (perl, ruby) to use "-x" for this
> purpose. A nice write-up at
>
> https://github.com/smikes/node/blob/minus-x-switch/doc/Minus-X-Switch-Proposal.md
>
> Amazingly, "-x" is available as an Emacs command-line switch...
I think that sounds really attractive, so I've added this to Emacs 29.
The new -x switch is like --script, but will kill Emacs when it reaches
the end of the script, and return the value of the final form as the
return value, so you can say use 0 at the end to signal success to the
caller.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
25671 <at> debbugs.gnu.org and Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 18 Apr 2022 11:02:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Thu, 05 May 2022 22:16:02 GMT)
Full text and
rfc822 format available.
Message #45 received at 25671 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> > Amazingly, "-x" is available as an Emacs command-line switch...
>
> I think that sounds really attractive, so I've added this to Emacs 29.
> The new -x switch is like --script, but will kill Emacs when it reaches
> the end of the script, and return the value of the final form as the
> return value, so you can say use 0 at the end to signal success to the
> caller.
Thanks - but it doesn't work correctly for me. Contrarily to --script,
my init file is being loaded with -x. Does that work correctly for you,
Lars?
TIA,
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Fri, 06 May 2022 12:06:02 GMT)
Full text and
rfc822 format available.
Message #48 received at 25671 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Thanks - but it doesn't work correctly for me. Contrarily to --script,
> my init file is being loaded with -x. Does that work correctly for you,
> Lars?
Nope. Should be fixed now.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#25671
; Package
emacs
.
(Sat, 07 May 2022 02:10:03 GMT)
Full text and
rfc822 format available.
Message #51 received at 25671 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Nope. Should be fixed now.
Better - thanks.
Michael.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 04 Jun 2022 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 327 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.