emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Phil Mason <phil.mason@broadcom.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Shell script block gives no output when evaluated
Date: Wed, 08 Feb 2012 07:36:37 -0700	[thread overview]
Message-ID: <87obt9nzok.fsf@gmx.com> (raw)
In-Reply-To: 2D76BBD878DB8B49BBE309F15526B38EC2DE@SJEXCHMB06.corp.ad.broadcom.com

"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/

      reply	other threads:[~2012-02-08 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 14:00 Shell script block gives no output when evaluated Phil Mason
2012-02-08 14:36 ` Eric Schulte [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obt9nzok.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=phil.mason@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).