From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Batch execution and --script Date: Wed, 29 Aug 2012 20:59:18 +0200 Message-ID: <87d329sewp.fsf@googlemail.com> References: <3611.1346264968@alphaville> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6nRH-0001Gl-43 for emacs-orgmode@gnu.org; Wed, 29 Aug 2012 14:56:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6nRF-0001MD-MM for emacs-orgmode@gnu.org; Wed, 29 Aug 2012 14:56:30 -0400 Received: from plane.gmane.org ([80.91.229.3]:49154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6nRF-0001M3-FM for emacs-orgmode@gnu.org; Wed, 29 Aug 2012 14:56:29 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T6nRE-0005u6-Cl for emacs-orgmode@gnu.org; Wed, 29 Aug 2012 20:56:28 +0200 Received: from e178054166.adsl.alicedsl.de ([85.178.54.166]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Aug 2012 20:56:28 +0200 Received: from tjolitz by e178054166.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Aug 2012 20:56:28 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Marcelo de Moraes Serpa writes: Hi Marcelo, > This is a subject that should be explored more. I see a lot of > potential in having CLI .el scripts (i.e taking the emacs GUI out of > the equation). I once asked a related question on stackoverflow, and recieved this answer that shows how to - become more independent of the location of the emacs executable - pass more than one argument on the shebang line at the same time: ,----------------------------------------------------------------------------- | Many unix variants only allow a single argument to the program on | the shebang line. Sad, but true. If you use #!/usr/bin/env emacs so | as not to depend on the location of the emacs executable, you can't | pass an argument at all. | | Chaining scripts is a possibility on some systems, but that too is | not supported everywhere. | | You can go the time-honored route of writing a script that is both | a shell script and an Emacs Lisp script (like Perl's if | $running_under_some_shell, for example). It sure looks hackish, but | it works. | | Elisp comments begin with ;, which in the shell separates two | up commands. So we can use a ; followed by a shell instruction to | vote switch over to Emacs, with the actual Lisp code beginning on the | 21 next line. Shells don't like an empty command though, so we need to | down find something that both the shell and Emacs treat as a no-op, so | vote put before the ;. The shell no-op command is :; you can write it | ":" as far as the shell is concerned, and Emacs parses that as a | constant at top level which is also a no-op. | | #! /bin/sh | ":"; exec emacs --no-site-file --script "$0" -- "$@" # -*-emacs-lisp-*- | (print (+ 2 2)) `----------------------------------------------------------------------------- Maybe thats interesting for you. The full question is here: http://stackoverflow.com/questions/6238331/emacs-shell-scripts-how-to-put-initial-options-into-the-script -- cheers, Thorsten