emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [babel] problem with sh blocks


From: Sebastien Vauban
Subject: Re: [O] [babel] problem with sh blocks
Date: Mon, 20 Feb 2012 13:34:46 +0100
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.0.92 (windows-nt)

Hi Andreas Leha,

Andreas Leha wrote:
> Hi Seb
>
>>> why is it, that I can not use this code in sh blocks (I get sh: 2: Bad
>>> substitution), even though it is valid when I run the tangled
>>> script?  Is this a known thing?
>>>
>>> #+begin_src sh :shebang "#!/bin/bash" :tangle test.sh
>>>   for i in *.org; do
>>>       echo cp "$i" "${i/%.org/.bak.org}"
>>>   done
>>> #+end_src
>>>
>>> How can I get the above block to execute?
>>
>> I just copied your block into a fresh "test.org" file, and eval'ed the code
>> block:
>>
>> #+begin_src sh :shebang "#!/bin/bash" :tangle test.sh
>>   for i in *.org; do
>>       echo cp "$i" "${i/%.org/.bak.org}"
>>   done
>> #+end_src
>>
>> #+results:
>> | cp | test-export4.org | test-export4.bak.org |
>> | cp | test-export5.org | test-export5.bak.org |
>> | cp | test-export7.org | test-export7.bak.org |
>>
>> Works perfectly for me, it seems.
>
> thanks for testing!
>
> That's what I'd like to get as well.  I tried with emacs -Q with no
> success.  Seems the sh block is not executed by my bash.
>
> After more thoughts on this my guess is that it has to do with dash
> being the default shell in debian.
>
> #+begin_src sh :shebang "#!/bin/bash" :tangle test.sh
>   echo $_
>   ls -l /bin/sh
> #+end_src
>
> #+RESULTS:
> | /bin/sh    |   |      |      |   |     |    |       |         |    |      |
> | lrwxrwxrwx | 1 | root | root | 4 | Sep | 27 | 14:23 | /bin/sh | -> | dash |
>
> How can I get this to be /bin/bash?  Preferably from within org mode,
> but I am grateful for any hint.

I have the following for my Emacs config:

--8<---------------cut here---------------start------------->8---
  (setq shell-file-name "bash")
  (setenv "SHELL" shell-file-name)
--8<---------------cut here---------------end--------------->8---

Note that this is related to an old discussion I had with Eric Schulte. See
http://lists.gnu.org/archive/html/emacs-orgmode/2009-12/msg00078.html.

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]