delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/12/20/17:02:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
Path: not-for-mail
From: Soren A <soren_andersen AT fastmail DOT fm>
Subject: retval of pipelined cmd in bash
Date: Fri, 20 Dec 2002 21:47:57 +0000 (UTC)
Organization: Sporadically Occasionally
Lines: 44
Message-ID: <Xns92EAAAF9FCFDBsorenagmaneSH@80.91.224.249>
X-Complaints-To: usenet AT main DOT gmane DOT org
User-Agent: Xnews/5.04.25
X-Archive: encrypt

Hallo Cygwains,

[Heck, I dunno... "Cygwinauts"?].

I have a possibly OT question, that is, a bash shell question. Lacking
the insight into the deepest reaches of shell-ology, I have come up
empty on all attempts to solve this one for myself. (Those attempts have
included doing `info bash' and reading the "Advanced Bash Scripting
Guide", an excellent resource available on the Web). 

I am writing a shell script that chains together several commands in a
pipeline -- very *nix-ish. The first command in the pipeline is an
invocation of `make'. Here's the entire script code -- I've tried many
very elaborate or bizarre things, before this: 
----------------------------------8<-----------------------------------
   function powermake
   {
	 declare -x LESS='-z-2$ -s~wR'
	 declare PAGER='/bin/less'
	 declare +x ECODE=
	 { make "$@" || ECODE=$? ; } 2>&1 | tee $MAKE_ERR_TO | \
	    /cdv/f/scr/colormake.pl | $PAGER -O"${MAKE_ERR_TO}.colorlog"
	 if [[ $ECODE ]]  # "0" and "1" are both TRUE; "null" is FALSE.
	   then $gvimexe --servername 'QUICKFIX' -q "$(cygpath -wla $MAKE_ERR_TO)"
	   else echo 'No "make" errors to diagnose: retval was ' '"'$ECODE'".'
	 fi
	 return $ECODE
   }
----------------------------------8<-----------------------------------

The problem I am trying to solve is how to get the return value of the
`make' tool. If there was an error I need to know about it. But as it
stands, nothing that i have tried will cause me to see the VIM editor
session start up; the value in ECODE is apparently always "0". 

Does anyone know how to do this -- how to pull out a return value from a
command in the middle of a pipeline? 

   Thanks,
     Soren
-- 
Yes, it's really Sören, not Soren.





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019