all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Frédéric Perrin" <fred.NO@SPAM.resel.fr>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs script that works on all platforms
Date: Thu, 20 May 2010 22:40:24 +0200	[thread overview]
Message-ID: <kggk4qytih3.fsf@pc-df-203.priv.enst-bretagne.fr> (raw)
In-Reply-To: mailman.15.1274382091.29716.help-gnu-emacs@gnu.org

Johan Andersson <johan.rejeep@gmail.com> writes:
> I have an Emacs script where the first line looks like this:
> #!/usr/bin/emacs --script
>
> However, on Mac OSX, Emacs is installed by default, but with an old
> version.
>
> I have also installed Emacs via Homebrew (compiled from source) and
> can run that with:
> /Usr/local/Cellar/emacs/23.2/Emacs.app/Contents/MacOS/Emacs
>
> So, to run the script with the Homebrew version, I could change the
> first line in my script to:
> #!/Usr/local/Cellar/emacs/23.2/Emacs.app/Contents/MacOS/Emacs
> --script
>
> That works, but I want this script to work on both GNU/Linux and Mac
> OSX (Both default and Homebrew version).
>
> I was thinking I could use env somehow, like this:
> #!/usr/bin/env emacs --script
>
> And then make emacs an alias or function that points to the correct
> binary depending on system. But it's still the default Emacs that is
> used.

In `/usr/bin/env emacs', env(1) will execvp(3) `emacs' ; so it won't
follow your shell aliases or functions.

Ideas :

Put ~/bin as the first thing in your $PATH, and make ~/bin/emacs a
symlink to the emacs you want to use. Then, use the `/usr/bin/env
emacs' trick.

Expand on the sesquicolon as described in [1]. Something like
(untested):

:; [ `uname` == "linux" ] && exec /usr/bin/emacs --batch -l $0 $* || exec /Usr/local/.../Emacs --batch -l $0 $*

[1] http://www.emacswiki.org/emacs/EmacsScripts

-- 
Fred


       reply	other threads:[~2010-05-20 20:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.15.1274382091.29716.help-gnu-emacs@gnu.org>
2010-05-20 20:40 ` Frédéric Perrin [this message]
     [not found] ` <3c0b258e-32ae-4ab8-b936-3d304f3e4771@34g2000prs.googlegroups.com>
2010-05-22 12:31   ` Emacs script that works on all platforms Tassilo Horn
2010-05-20 19:01 Johan Andersson
2010-05-21 13:24 ` Tassilo Horn
2010-05-27 12:51   ` Johan Andersson
     [not found]   ` <mailman.0.1274964713.14889.help-gnu-emacs@gnu.org>
2010-05-27 14:12     ` Pascal J. Bourguignon

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=kggk4qytih3.fsf@pc-df-203.priv.enst-bretagne.fr \
    --to=fred.no@spam.resel.fr \
    --cc=help-gnu-emacs@gnu.org \
    /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.