From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: do sh source blocks ignore args? [7.8.09] Date: Thu, 26 Apr 2012 14:59:50 -0400 Message-ID: <87ehraxqs9.fsf@gmx.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SNVna-00055C-6G for emacs-orgmode@gnu.org; Thu, 26 Apr 2012 17:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SNVnX-0007re-Tp for emacs-orgmode@gnu.org; Thu, 26 Apr 2012 17:00:21 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:40728) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SNVnX-0007rK-NG for emacs-orgmode@gnu.org; Thu, 26 Apr 2012 17:00:19 -0400 In-Reply-To: (Neil Best's message of "Thu, 26 Apr 2012 15:44:26 -0500") 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: Neil Best Cc: emacs-orgmode@gnu.org Neil Best writes: > Can sh source block take arguments? I get nothing. > > #+NAME: test(foo="bar") > #+BEGIN_SRC sh :session :results output verbatim replace > echo "1. foo is $foo" > echo "2. foo is ${foo}" > #+END_SRC > > #+RESULTS: > : 1. foo is > : 2. foo is > > > . . . but this is fine: > > #+NAME: test2 > #+BEGIN_SRC sh :var foo="bar" :session :results output verbatim > replace > echo "1. foo is $foo" > echo "2. foo is ${foo}" > #+END_SRC > > #+RESULTS: > : 1. foo is bar > : 2. foo is bar > > When I tried this: > > #+CALL: test("baz") > > I get "reference 'test' not found in this buffer" -- what does this > mean? I got a similar message when I tried to define a simple call > using an R fragment that has a session associated with it. Evaluating > the code block with the default argument works fine, but a #+CALL: > construct fails. Maybe this is a separate issue. > > I trolled the web for relevant examples or reports but found none. My > setup is pretty much out-of-the-box. I am on Ubuntu Oneiric so sh is > a symlink to dash. I was not aware of dash until now so I don't know > what the implications of that are. > > This example may be overly trivial. My ultimate goal is to generate > shell scripts as function of the argument and tangle them out > something like this: > > #+BEGIN_SRC sh :tangle someArg.sh > <> > #+END_SRC > > So the results of the "function" will be lines of script code with > variables already interpolated using echo and a heredoc. Note that > test2 will not allow me to paramterize this, AFAIK. I'll have to > write each tangle block by hand but there's a small number of them. > If there is a more clever way I am certainly interested, but it seems > irrelevant until I understand what is happening above. Thanks. I am > very intrigued by LP possibilities using Org after messing with Sweave > for a year+, so please bear with me as I cut my teeth. > Hi Neil, Are you using the latest version of Org-mode? I ask because all of your examples work as expected on my system, specifically I get the following... Best, #+NAME: test(foo="bar") #+BEGIN_SRC sh :session :results output verbatim replace echo "1. foo is $foo" echo "2. foo is ${foo}" #+END_SRC #+RESULTS: test : 1. foo is bar : 2. foo is bar . . . but this is fine: #+NAME: test2 #+BEGIN_SRC sh :var foo="bar" :session :results output verbatim replace echo "1. foo is $foo" echo "2. foo is ${foo}" #+END_SRC #+RESULTS: test2 : 1. foo is bar : 2. foo is bar #+RESULTS: : 1. foo is bar : 2. foo is bar When I tried this: #+CALL: test("baz") #+RESULTS: test("baz") : 1. foo is baz : 2. foo is baz -- Eric Schulte http://cs.unm.edu/~eschulte/