From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org babel execute shell in sh? Date: Mon, 12 Mar 2012 15:10:58 -0400 Message-ID: <4663.1331579458@alphaville> References: <87fwdj67q2.fsf@goochesa.de> <3596.1331353274@alphaville> <87pqchg6ab.fsf@gmx.com> <874ntt6ah1.fsf@goochesa.de> <87aa3ld8yp.fsf@gmx.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AeD-0002Il-8B for emacs-orgmode@gnu.org; Mon, 12 Mar 2012 15:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7Ae6-0004Ma-Qs for emacs-orgmode@gnu.org; Mon, 12 Mar 2012 15:11:08 -0400 Received: from g4t0017.houston.hp.com ([15.201.24.20]:30019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Ae6-0004M9-Kb for emacs-orgmode@gnu.org; Mon, 12 Mar 2012 15:11:02 -0400 In-Reply-To: Message from Eric Schulte of "Mon, 12 Mar 2012 13:29:02 EDT." <87aa3ld8yp.fsf@gmx.com> 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: Eric Schulte Cc: nicholas.dokos@hp.com, Tom Regner , emacs-orgmode@gnu.org, Panruo Wu Eric Schulte wrote: > I just pushed up a patch which adds this behavior. It does result in > some odd new possibilities, such as the following. > > #+begin_src sh :shebang #!/bin/cat > foo > #+end_src > > #+RESULTS: > | #!/bin/cat | > | | > | foo | > Maybe my settings are slightly different, but the new bits give me ,---- | #+begin_src sh :shebang #!/bin/cat | foo | #+end_src | | #+RESULTS: | : foo `---- They also give me sensible results with the original example: ,---- | #+begin_src sh :shebang #!/bin/bash | for np in {1..32} | do | echo $np | done | #+end_src | | #+RESULTS: | | 1 | | | 2 | | | 3 | | |... | | | 31 | | | 32 | `---- The only potentially confusing case I've found is the following: ,---- | #+begin_src sh | #!/bin/bash | for np in {1..32} | do | echo $np | done | #+end_src | | #+RESULTS: | : {1..32} `---- with the shebang as part of the script. I'd argue it's doing the right thing however: if one remembers that sh is the default command, this is equivalent to the command line invocation: ,---- | $ sh foo.sh `---- where foo.sh contains --8<---------------cut here---------------start------------->8--- #!/bin/bash for np in {1..32} do echo $np done --8<---------------cut here---------------end--------------->8--- and that too gives: ,---- | $ sh foo.sh | {1..32} `---- whereas ,---- | $ ./foo.sh | 1 | 2 | 3 | ... | 31 | 32 `---- In other words, sh does not interpret the shebang: that is only done by the exec system call. Nick