emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: do sh source blocks ignore args? [7.8.09]
  2012-04-26 20:44 do sh source blocks ignore args? [7.8.09] Neil Best
@ 2012-04-26 18:59 ` Eric Schulte
  2012-04-26 21:16   ` Neil Best
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2012-04-26 18:59 UTC (permalink / raw)
  To: Neil Best; +Cc: emacs-orgmode

Neil Best <nbest@ci.uchicago.edu> 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
>   <<script("someArg")>>
> #+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/

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

* do sh source blocks ignore args? [7.8.09]
@ 2012-04-26 20:44 Neil Best
  2012-04-26 18:59 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Best @ 2012-04-26 20:44 UTC (permalink / raw)
  To: emacs-orgmode

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
  <<script("someArg")>>
#+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.

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

* Re: do sh source blocks ignore args? [7.8.09]
  2012-04-26 18:59 ` Eric Schulte
@ 2012-04-26 21:16   ` Neil Best
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Best @ 2012-04-26 21:16 UTC (permalink / raw)
  To: emacs-orgmode

Org-mode version 7.8.09

How could this be?

I ran it in a separate, minimally configured Emacs and got the good
behavior, so org-version must be lying somehow or else not all of the
functions were redefined when I upgraded.  I thought a reload
uncompiled would take care of this.  I'll restart emacs and try it
again.  Thanks for the sanity check.



On Thu, Apr 26, 2012 at 1:59 PM, Eric Schulte <eric.schulte@gmx.com> wrote:
> Neil Best <nbest@ci.uchicago.edu> 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
>>   <<script("someArg")>>
>> #+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/

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

end of thread, other threads:[~2012-04-26 21:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-26 20:44 do sh source blocks ignore args? [7.8.09] Neil Best
2012-04-26 18:59 ` Eric Schulte
2012-04-26 21:16   ` Neil Best

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