From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [kvm-unit-tests PATCH v3 3/6] arch-run: reduce return code ambiguity Date: Wed, 2 Mar 2016 13:57:00 +0100 Message-ID: <20160302125659.GA2007@potion.brq.redhat.com> References: <1456772003-27911-1-git-send-email-drjones@redhat.com> <1456772003-27911-4-git-send-email-drjones@redhat.com> <56D609AC.80303@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Jones , kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751536AbcCBM5F (ORCPT ); Wed, 2 Mar 2016 07:57:05 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 36C9C821C3 for ; Wed, 2 Mar 2016 12:57:04 +0000 (UTC) Content-Disposition: inline In-Reply-To: <56D609AC.80303@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 2016-03-01 22:29+0100, Paolo Bonzini: > On 29/02/2016 19:53, Andrew Jones wrote: >> + errors=$("${@}" 2>&1 1>&${stdout} | tee >(cat - 1>&2); exit ${PIPESTATUS[0]}) > > Whoa! :) So stdout goes to {stdout} and from there to the real stdout; > stderr instead is tee'd to stderr and $errors. Yeah. :) > Is the "tee" and "cat" necessary? Can you just use printf somewhat like: They are, if you want want to improve chances of getting the original order of stdout and stderr. > # stdout to {stdout}, stderr to $errors > errors=$("$@" 2>&1 1>&${stdout}) > ret=$? > printf '%s\n' "$errors" >&2 (Previous version did this any my suggestion was to change it ...) > ? Or something like that (for example I'm not sure if you need the \n). Trying to improve the original solution, What about a bit more understandable errors=$("${@}" 2> >(tee >(cat) >&2) >&$stdout) ? Which gets rid of some redirections and PIPESTATUS. > In either case, stdout and stderr can be mixed. Yes, we can't have a good solution here. >> + temp_file RUNTIME_arch_run <(echo "#!/bin/bash"; cat scripts/arch-run.bash "$TEST_DIR/run") > > Please use a pipe instead of a <(...): (Is it for aesthetic reasons?) Thanks.