emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] problem with sh blocks
@ 2012-02-20  7:49 Andreas Leha
  2012-02-20  8:56 ` Sebastien Vauban
  2012-02-20 13:59 ` Eric Schulte
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Leha @ 2012-02-20  7:49 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

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?

Thanks in advance,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20  7:49 [babel] problem with sh blocks Andreas Leha
@ 2012-02-20  8:56 ` Sebastien Vauban
  2012-02-20  9:23   ` Andreas Leha
  2012-02-20 13:59 ` Eric Schulte
  1 sibling, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2012-02-20  8:56 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Andreas Leha,

Andreas Leha wrote:
> Hi all,
>
> 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, on:

GNU Emacs 24.0.92.1 (i386-mingw-nt5.1.2600) of 2012-01-23 on MARVIN
Org-mode version 7.8.03 (release_7.8.03.410.g77fb)

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20  8:56 ` Sebastien Vauban
@ 2012-02-20  9:23   ` Andreas Leha
  2012-02-20 12:34     ` Sebastien Vauban
  2012-02-20 12:46     ` Bernt Hansen
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Leha @ 2012-02-20  9:23 UTC (permalink / raw)
  To: emacs-orgmode

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, on:
>
> GNU Emacs 24.0.92.1 (i386-mingw-nt5.1.2600) of 2012-01-23 on MARVIN
> Org-mode version 7.8.03 (release_7.8.03.410.g77fb)
>
> Best regards,
>   Seb

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.

(Somehow this question seems familiar to me...)

My setup:

I am on Debian testing with
GNU Emacs 24.0.93.1 (x86_64-pc-linux-gnu, GTK+ Version 3.2.3) of
2012-02-16 on zelenka, modified by Debian
Org-mode version 7.8.03, pulled last week
  (how do I get the release info as well?)

Regards,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20  9:23   ` Andreas Leha
@ 2012-02-20 12:34     ` Sebastien Vauban
  2012-02-20 12:46     ` Bernt Hansen
  1 sibling, 0 replies; 8+ messages in thread
From: Sebastien Vauban @ 2012-02-20 12:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20  9:23   ` Andreas Leha
  2012-02-20 12:34     ` Sebastien Vauban
@ 2012-02-20 12:46     ` Bernt Hansen
  2012-02-23 20:08       ` Andreas Leha
  1 sibling, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2012-02-20 12:46 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Org-mode version 7.8.03, pulled last week
>   (how do I get the release info as well?)

If you are running from a git repository then M-x org-version should
show the results of 'git describe' automatically.

C-u M-x org-version RET
Org-mode version 7.8.03 (release_7.8.03.420.gaf2a4)

Regards,
Bernt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20  7:49 [babel] problem with sh blocks Andreas Leha
  2012-02-20  8:56 ` Sebastien Vauban
@ 2012-02-20 13:59 ` Eric Schulte
  2012-02-20 17:51   ` Andreas Leha
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2012-02-20 13:59 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Hi,

As with the other recent sh-block email, the problem is likely due to
the interpreter used (e.g., bash as compared to dash).  See the value of
`org-babel-sh-command' which defaults to "sh" which defaults to a POSIX
rather than bash shell on many systems.

Best,

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi all,
>
> 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?
>
> Thanks in advance,
> Andreas
>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20 13:59 ` Eric Schulte
@ 2012-02-20 17:51   ` Andreas Leha
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Leha @ 2012-02-20 17:51 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

Hi Eric,
> Hi,
>
> As with the other recent sh-block email, the problem is likely due to
> the interpreter used (e.g., bash as compared to dash).  See the value of
> `org-babel-sh-command' which defaults to "sh" which defaults to a POSIX
> rather than bash shell on many systems.
>
> Best,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi all,
>>
>> 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?
>>
>> Thanks in advance,
>> Andreas
>>
>>

thanks a lot!  The org-babel-sh-command did the trick!

Cheers,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [babel] problem with sh blocks
  2012-02-20 12:46     ` Bernt Hansen
@ 2012-02-23 20:08       ` Andreas Leha
  0 siblings, 0 replies; 8+ messages in thread
From: Andreas Leha @ 2012-02-23 20:08 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Org-mode version 7.8.03, pulled last week
>>   (how do I get the release info as well?)
>
> If you are running from a git repository then M-x org-version should
> show the results of 'git describe' automatically.
>
> C-u M-x org-version RET
> Org-mode version 7.8.03 (release_7.8.03.420.gaf2a4)
>
> Regards,
> Bernt

Hi Bernt,

thanks.  I did not get the git describe part.

Now looking at the code of org-version, I saw, that I
get this only, when I run org from the repository (I did make install and
load from another place).  Kind of obvious.....

Now I am loading org from the repository.  Bit anyway, since I have some
changes committed locally on top, that won't give useful (useful to others)
information.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-23 20:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20  7:49 [babel] problem with sh blocks Andreas Leha
2012-02-20  8:56 ` Sebastien Vauban
2012-02-20  9:23   ` Andreas Leha
2012-02-20 12:34     ` Sebastien Vauban
2012-02-20 12:46     ` Bernt Hansen
2012-02-23 20:08       ` Andreas Leha
2012-02-20 13:59 ` Eric Schulte
2012-02-20 17:51   ` Andreas Leha

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).