emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Shell script block gives no output when evaluated
@ 2012-02-08 14:00 Phil Mason
  2012-02-08 14:36 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Mason @ 2012-02-08 14:00 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hello all,

If I evaluate the following source block in emacs 23.1.1, org mode v7.8.03 it reports that it produces no output:

     #+begin_src sh :results replace
       foo=1
       if [[ -n "$foo" ]]; then
           echo "foo has been defined (and has value $foo)"
       else
           echo "foo has not been defined"
       fi       
       if [[ -n "$bar" ]]; then
           echo "bar has been defined (and has value $bar)"
       else
           echo "bar has not been defined"
       fi       
     #+end_src

Confusingly if I remove either if block then the results for the remaining one is correct and if I run the same code from within an actual script it works as I expect (foo is defined, bar is not). Can anybody provide any clues about what I'm doing wrong.

Thanks in advance

Phil

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

* Re: Shell script block gives no output when evaluated
  2012-02-08 14:00 Shell script block gives no output when evaluated Phil Mason
@ 2012-02-08 14:36 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2012-02-08 14:36 UTC (permalink / raw)
  To: Phil Mason; +Cc: emacs-orgmode@gnu.org

"Phil Mason" <phil.mason@broadcom.com> writes:

> Hello all,
>
> If I evaluate the following source block in emacs 23.1.1, org mode
> v7.8.03 it reports that it produces no output:
>
>      #+begin_src sh :results replace
>        foo=1
>        if [[ -n "$foo" ]]; then
>            echo "foo has been defined (and has value $foo)"
>        else
>            echo "foo has not been defined"
>        fi       
>        if [[ -n "$bar" ]]; then
>            echo "bar has been defined (and has value $bar)"
>        else
>            echo "bar has not been defined"
>        fi       
>      #+end_src
>
> Confusingly if I remove either if block then the results for the
> remaining one is correct and if I run the same code from within an
> actual script it works as I expect (foo is defined, bar is not). Can
> anybody provide any clues about what I'm doing wrong.
>
> Thanks in advance
>

I believe adding :results output should fix this problem, as what you
want is a collection of the text printed to STDOUT.

With that change I get the following...

#+begin_src sh :results replace output
  foo=1
  if [[ -n "$foo" ]]; then
      echo "foo has been defined (and has value $foo)"
  else
      echo "foo has not been defined"
  fi       
  if [[ -n "$bar" ]]; then
      echo "bar has been defined (and has value $bar)"
  else
      echo "bar has not been defined"
  fi       
#+end_src

#+RESULTS:
: foo has been defined (and has value 1)
: bar has not been defined

>
> Phil
>
>

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

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

end of thread, other threads:[~2012-02-08 14:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-08 14:00 Shell script block gives no output when evaluated Phil Mason
2012-02-08 14:36 ` Eric Schulte

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