[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Shell script block gives no output when evaluated
From: |
Eric Schulte |
Subject: |
Re: [O] Shell script block gives no output when evaluated |
Date: |
Wed, 08 Feb 2012 07:36:37 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) |
"Phil Mason" <address@hidden> 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/