From: Phil Sainty <psainty@orcon.net.nz>
To: Thibault Polge <thibault@thb.lt>
Cc: 31220@debbugs.gnu.org,
bug-gnu-emacs
<bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>
Subject: bug#31220: 25.3; emacs --script breaks command-line arguments handling
Date: Fri, 20 Apr 2018 11:26:04 +1200 [thread overview]
Message-ID: <142916a7c3b38f0c0959de098cf398b5@webmail.orcon.net.nz> (raw)
In-Reply-To: <87tvs7rmo8.fsf@thb.lt>
On 2018-04-20 08:00, Thibault Polge wrote:
> When running an Emacs Lisp script with either the `#!emacs --script`
> shebang or by invoking `emacs --script script.el`, Emacs:
>
> 1. immediately processes command-line arguments it knows, even if they
> were passed *after* --script. It means, for example, that no script
> can provide a meaningful --help script, because Emacs always
> intercepts help.
Writing elisp scripts is fiddly, but it *is* possible to handle
arbitrary arguments cleanly.
As with many programs, you can use the argument '--' to tell Emacs not
to process further arguments as if they were options. e.g.:
$ emacs --script -- --help
Which will pass '--' and '--help' to the script.
Some boiler-plate for an elisp script is:
#!/bin/sh
":"; exec emacs -Q --script "$0" -- "$@" # -*-emacs-lisp-*-
(pop argv) # Remove the "--" argument
# ...
# Always exit explicitly. This returns the desired exit
# status, and also avoids the need to (setq argv nil).
(kill-emacs 0)
For more information see:
* https://stackoverflow.com/a/6259330/324105
* https://swsnr.de/posts/emacs-script-pitfalls
next prev parent reply other threads:[~2018-04-19 23:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 20:00 bug#31220: 25.3; emacs --script breaks command-line arguments handling Thibault Polge
2018-04-19 23:26 ` Phil Sainty [this message]
2018-04-20 6:42 ` Eli Zaretskii
[not found] ` <handler.31220.B.152416813411957.ack@debbugs.gnu.org>
2018-04-21 7:57 ` bug#31220: Acknowledgement (25.3; emacs --script breaks command-line arguments handling) Thibault Polge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=142916a7c3b38f0c0959de098cf398b5@webmail.orcon.net.nz \
--to=psainty@orcon.net.nz \
--cc=31220@debbugs.gnu.org \
--cc=bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org \
--cc=thibault@thb.lt \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.