11

I'm experimenting with sourcing data from org-mode into my shell scripts and I've run across a weirdness:

#+tblname: simple-table
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |

#+name: work-with-simple-list-shell
#+begin_src shell :var tbl=simple-table
echo "$tbl"
#+end_src

#+RESULTS: work-with-simple-list-shell
: 1

#+name: work-with-simple-list-sh
#+begin_src sh :var tbl=simple-table
echo "$tbl"
#+end_src

#+RESULTS: work-with-simple-list-sh
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |

Any idea what is going on?

  • 1
    It seems like ob-sh is deprecated in favour of ob-shell ( As seen in this thread of the mailing list). – dangom Sep 6 '17 at 12:29
  • If they are only aliases to each other then why the difference in behaviour? – stsquad Sep 6 '17 at 12:35
  • Something weird with your config. I don't see any difference in behaviour here. If I echo $SHELL, I get the same shell for both. Also, did you try C-c C-v I to check whether both src-blocks have the same header-args? – dangom Sep 6 '17 at 13:00
  • @dangom: hmm same set of header args save for Lang:shell vs Lang:sh and header-args:shell vs header-args:sh but both set to nil. $SHELL reports bash in both cases. – stsquad Sep 6 '17 at 13:18
7

The difference is which shell gets called to evaluate your block. shell calls whatever your default shell is while sh calls /bin/sh specifically. Your default shell is probably bash, which is an extension of sh. echo $0 will tell you what executable your shell is running:

#+BEGIN_SRC shell
echo $0
#+END_SRC

#+RESULTS:
: /bin/bash


#+BEGIN_SRC sh
echo $0
#+END_SRC

#+RESULTS:
: sh

Any of the shells in org-babel-shell-names that is installed on your system will work.

  • I'm still confused as to why the input variable gets so munged. Is this bash doing something different with the variable? – stsquad Dec 29 '17 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.