bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to deal with errors in <()?


From: Linda Walsh
Subject: Re: How to deal with errors in <()?
Date: Sat, 14 Mar 2015 06:46:12 -0700
User-agent: Thunderbird



Peng Yu wrote:
Hi,

http://mywiki.wooledge.org/ProcessSubstitution

The above webpage says the following.

commandA <(commandB; [commandB's exit code is available here from $?])
[commandB's exit code cannot be obtained from here.  $? holds
commandA's exit code]


Does anybody have a good solution for this situation? Thanks.
--
It's not a pretty solution, but how about some variation of:

alias cmda='cat >/dev/tty'        ## 1st cmd
alias cmdb='(echo "foo";exit 2)'  ## command executes, but exits w/err=2
read status < <(cmda <(cmdb; echo "status=$?" >&2) 2>&1)
status=2
foo
---
not ideal, but it does get you the status.
Instead of echoing it you could assigned it to a var,
and test the value and only print status if non-zero,
something like:

  ((status=$?)) && echo "status=$status

instead of just the echo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]