emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tom Regner <tom@goochesa.de>
To: nicholas.dokos@hp.com
Cc: Panruo Wu <pwu@mymail.mines.edu>, emacs-orgmode@gnu.org
Subject: Re: org babel execute shell in sh?
Date: Sat, 10 Mar 2012 07:33:53 +0100	[thread overview]
Message-ID: <c2e17679-2d56-4736-b500-24baa2a1e9ac@email.android.com> (raw)
In-Reply-To: <3596.1331353274@alphaville>



Nick Dokos <nicholas.dokos@hp.com> schrieb:

>Tom Regner <tom@goochesa.de> wrote:
>
>> Hi,
>>
>> Panruo Wu <pwu@mymail.mines.edu> writes:
>>
>> > Dear list,
>> >
>> >
>> > #+begin_src sh=C2=A0
>> > for np in {1..32}
>> > do
>> > =C2=A0 =C2=A0 echo $np
>> > done
>> > #+end_src
>> >
>> > when executing, the output only shows
>> > {1..32}
>> > which is clearly not I want..
>> >
>> > After some investigation, I found that orgmode
>> > uses "sh" that cannot understand the for loop above.
>> >
>> > My question is, how can I suggest orgmode to use
>> > "bash" to execute shell script?
>> >
>> > I tried :shebang #!/bin/bash but it does not work
>>
>> I have the following in my config:
>>
>> --------------------%<--------------------------
>>       I really like org-babel to use zsh
>>       #+begin_src emacs-lisp
>>         (setq org-babel-sh-command "zsh")
>>       #+end_src
>> --------------------%<--------------------------
>>
>> It is apparently not possible to set this variable via #+BIND: to
>only
>> change this for one code block, at least I did not succeed to do so
>in
>> my attempts to do so -- but maybe I just didn't read enough of the
>> documentation to /get it right/.
>>
>
>You are right that it is not possible: #+BIND is effective only when
>you
>are exporting - basically, people wanted to change various setting on
>export, and adding options for each and every one was too much, so
>Carsten implemented BIND as a general mechanism for that. But it does
>not apply to anything else; in particular, code block evaluation is
>completely separate.
>
>But you can use general emacs mechanisms to set it for a particular
>file:
>that's what file local variables are all about:
>
>(info "(emacs)Local Variables in Files")
>
>Nick
Ah, I didn't know that about BIND; but I do know file local variables. I don't need them in this case, as I always want to use zsh. And the OP asked for a different shell for one code block only, not the whole file.

But I'm often bitten by the distinction between export and tangling -- :padline, :shebang come to mind, where I expected org-babel to honour the setting in both cases.

well you live and learn: -) And org-mode truly is a joy to use, a marvelous piece of software, without which I couldn't do all my work im emacs.

Tom
>
>> I don't know, if zsh||bash instead of sh breaks any assumptions
>org-mode
>> makes about the environment in which sh code blocks are executed; up
>> until now it works like a charm.
>>
>> Kind regards,
>> Tom
>>


--
http://www.tomsdiner.de
xmpp: tom@sec.goochesa.de

  reply	other threads:[~2012-03-10  6:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 17:25 org babel execute shell in sh? Panruo Wu
2012-03-08  0:22 ` Nick Dokos
2012-03-08  4:24 ` Tom Regner
2012-03-09 20:34   ` Panruo Wu
2012-03-10  4:21   ` Nick Dokos
2012-03-10  6:33     ` Tom Regner [this message]
2012-03-12  4:34       ` Eric Schulte
2012-03-12 16:38         ` Tom Regner
2012-03-12 17:29           ` Eric Schulte
2012-03-12 19:10             ` Nick Dokos

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2e17679-2d56-4736-b500-24baa2a1e9ac@email.android.com \
    --to=tom@goochesa.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.com \
    --cc=pwu@mymail.mines.edu \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).