Subject: bug#25671: Feature request: emacs -Q --script as a single binary

From: Clément Pit--Claudel <[email-masked]>
Date: Thu, 9 Feb 2017 16:14:41 -0500

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.