all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25671: Feature request: emacs -Q --script as a single binary
@ 2017-02-09 21:14 Clément Pit--Claudel
  2017-02-09 21:27 ` Glenn Morris
  2017-02-10  7:37 ` Eli Zaretskii
  0 siblings, 2 replies; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-09 21:14 UTC (permalink / raw)
  To: 25671


[-- Attachment #1.1: Type: text/plain, Size: 1138 bytes --]

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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-09 21:14 bug#25671: Feature request: emacs -Q --script as a single binary Clément Pit--Claudel
@ 2017-02-09 21:27 ` Glenn Morris
  2017-02-09 21:32   ` Clément Pit--Claudel
  2017-02-10  7:37 ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2017-02-09 21:27 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 25671


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.)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-09 21:27 ` Glenn Morris
@ 2017-02-09 21:32   ` Clément Pit--Claudel
  0 siblings, 0 replies; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-09 21:32 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 25671


[-- Attachment #1.1: Type: text/plain, Size: 433 bytes --]

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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-09 21:14 bug#25671: Feature request: emacs -Q --script as a single binary Clément Pit--Claudel
  2017-02-09 21:27 ` Glenn Morris
@ 2017-02-10  7:37 ` Eli Zaretskii
  2017-02-10 14:17   ` Clément Pit--Claudel
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-02-10  7:37 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 25671

> From: Clément Pit--Claudel <clement.pitclaudel@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10  7:37 ` Eli Zaretskii
@ 2017-02-10 14:17   ` Clément Pit--Claudel
  2017-02-10 15:02     ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-10 14:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25671


[-- Attachment #1.1: Type: text/plain, Size: 701 bytes --]

On 2017-02-10 02:37, Eli Zaretskii wrote:
>> From: Clément Pit--Claudel <clement.pitclaudel@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?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 14:17   ` Clément Pit--Claudel
@ 2017-02-10 15:02     ` Eli Zaretskii
  2017-02-10 16:45       ` Clément Pit--Claudel
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-02-10 15:02 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 25671

> Cc: 25671@debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel@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?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 15:02     ` Eli Zaretskii
@ 2017-02-10 16:45       ` Clément Pit--Claudel
  2017-02-10 16:58         ` Eli Zaretskii
  2017-02-10 17:32         ` Glenn Morris
  0 siblings, 2 replies; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-10 16:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25671


[-- Attachment #1.1: Type: text/plain, Size: 703 bytes --]

On 2017-02-10 10:02, Eli Zaretskii wrote:
>> Cc: 25671@debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel@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?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 16:45       ` Clément Pit--Claudel
@ 2017-02-10 16:58         ` Eli Zaretskii
  2017-02-10 20:21           ` Clément Pit--Claudel
  2017-02-10 17:32         ` Glenn Morris
  1 sibling, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-02-10 16:58 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 25671

> Cc: 25671@debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel@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?)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 16:45       ` Clément Pit--Claudel
  2017-02-10 16:58         ` Eli Zaretskii
@ 2017-02-10 17:32         ` Glenn Morris
  2017-02-10 20:21           ` Clément Pit--Claudel
  1 sibling, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2017-02-10 17:32 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: 25671

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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 17:32         ` Glenn Morris
@ 2017-02-10 20:21           ` Clément Pit--Claudel
  0 siblings, 0 replies; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-10 20:21 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 25671


[-- Attachment #1.1: Type: text/plain, Size: 577 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2017-02-10 16:58         ` Eli Zaretskii
@ 2017-02-10 20:21           ` Clément Pit--Claudel
  0 siblings, 0 replies; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-02-10 20:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 25671


[-- Attachment #1.1: Type: text/plain, Size: 1113 bytes --]

On 2017-02-10 11:58, Eli Zaretskii wrote:
>> Cc: 25671@debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel@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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2022-04-18 11:01     ` bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary Lars Ingebrigtsen
@ 2022-05-05 22:14       ` Michael Heerdegen
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Heerdegen @ 2022-05-05 22:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25671, Glenn Morris, Stefan Monnier, 20682

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-05-05 22:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 21:14 bug#25671: Feature request: emacs -Q --script as a single binary Clément Pit--Claudel
2017-02-09 21:27 ` Glenn Morris
2017-02-09 21:32   ` Clément Pit--Claudel
2017-02-10  7:37 ` Eli Zaretskii
2017-02-10 14:17   ` Clément Pit--Claudel
2017-02-10 15:02     ` Eli Zaretskii
2017-02-10 16:45       ` Clément Pit--Claudel
2017-02-10 16:58         ` Eli Zaretskii
2017-02-10 20:21           ` Clément Pit--Claudel
2017-02-10 17:32         ` Glenn Morris
2017-02-10 20:21           ` Clément Pit--Claudel
  -- strict thread matches above, loose matches on Subject: below --
2015-05-28 13:57 bug#20682: 25.0.50; Enable users to combine --script and --quick Michael Heerdegen
2015-05-28 18:48 ` Stefan Monnier
2015-05-28 20:30   ` Glenn Morris
2022-04-18 11:01     ` bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary Lars Ingebrigtsen
2022-05-05 22:14       ` Michael Heerdegen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.