From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Shell script block gives no output when evaluated Date: Wed, 08 Feb 2012 07:36:37 -0700 Message-ID: <87obt9nzok.fsf@gmx.com> References: <2D76BBD878DB8B49BBE309F15526B38EC2DE@SJEXCHMB06.corp.ad.broadcom.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv8v6-0003UM-UJ for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv8v1-0001yG-1P for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:52 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:58267) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rv8v0-0001y8-P3 for emacs-orgmode@gnu.org; Wed, 08 Feb 2012 09:54:46 -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: Phil Mason Cc: "emacs-orgmode@gnu.org" "Phil Mason" 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/