diff mbox

cbuild2/lib/common.sh: redirect trace/error/warning, etc. to stderr.

Message ID 1381945612-31506-1-git-send-email-ryan.arnold@linaro.org
State New
Headers show

Commit Message

Ryan S. Arnold Oct. 16, 2013, 5:46 p.m. UTC
From: "Ryan S. Arnold" <ryan.arnold@linaro.org>

Redirecting all tracing messages to standard error prevents tracing from
polluting subshell invocation return values.  This is important when a
function is executed in a subshell and its output is gathered into a
string variable, such as get_source.
---
 lib/common.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Rob Savoye Oct. 16, 2013, 5:49 p.m. UTC | #1
On 10/16/2013 11:46 AM, Ryan S. Arnold wrote:
> From: "Ryan S. Arnold" <ryan.arnold@linaro.org>
>
> Redirecting all tracing messages to standard error prevents tracing from
> polluting subshell invocation return values.  This is important when a
> function is executed in a subshell and its output is gathered into a
> string variable, such as get_source
  Looks ok. Eventually all the TRACEs will be gone anyway, they're just
there now as a debugging aid.

    - rob -
Ryan S. Arnold Oct. 17, 2013, 1:59 a.m. UTC | #2
On Wed, Oct 16, 2013 at 12:49 PM, Rob Savoye <rob.savoye@linaro.org> wrote:
> On 10/16/2013 11:46 AM, Ryan S. Arnold wrote:
>> From: "Ryan S. Arnold" <ryan.arnold@linaro.org>
>>
>> Redirecting all tracing messages to standard error prevents tracing from
>> polluting subshell invocation return values.  This is important when a
>> function is executed in a subshell and its output is gathered into a
>> string variable, such as get_source
>   Looks ok. Eventually all the TRACEs will be gone anyway, they're just
> there now as a debugging aid.
>
>     - rob -
>
Pushed to master with slight variations to add stdout to stderr
redirection in a few more cases.

commit e605da20749479c65fabeb0b21def73c1c345a1d
Author: Ryan S. Arnold <ryan.arnold@linaro.org>
Date:   Wed Oct 16 20:55:44 2013 -0500

    lib/common.sh: redirect trace/error/warning, etc. to stderr.

    Redirecting all tracing messages to standard error prevents tracing from
    polluting subshell invocation return values.  This is important when a
    function is executed in a subshell and it's output is gathered into a
    string variable, such as get_source.

Ryan S. Arnold
diff mbox

Patch

diff --git a/lib/common.sh b/lib/common.sh
index c307d93..397899c 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -60,33 +60,33 @@  dryrun()
 
 trace()
 {
-    echo "TRACE(#${BASH_LINENO}): ${FUNCNAME[1]} ($*)"
+    echo "TRACE(#${BASH_LINENO}): ${FUNCNAME[1]} ($*)" 1>&2
 
 }
 
 fixme()
 {
-    echo "FIXME(#${BASH_LINENO}): ${FUNCNAME[1]} ($*)"
+    echo "FIXME(#${BASH_LINENO}): ${FUNCNAME[1]} ($*)" 1>&2
 
 }
 
 error()
 {
-    echo "ERROR (#${BASH_LINENO}): $1"
+    echo "ERROR (#${BASH_LINENO}): $1" 1>&2
     return 1
 }
 
 warning()
 {
     if test "${verbose}" -gt 0; then
-	echo "WARNING: $1"
+	echo "WARNING: $1" 1>&2
     fi
 }
 
 notice()
 {
     if test "${verbose}" -gt 0; then
-	echo "NOTE: $1"
+	echo "NOTE: $1" 1>&2
     fi
 }