From c2474ae5961abe48311d00048389ddf569a320c1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Aug 2011 18:27:44 -0400 Subject: [PATCH] common.sh: tweak color order for `set -x` love If you trace any script with `set -x` enabled, bash will dump the color variables and all of your output will be colored. So move the "reset" color to last so that the bleeding is localized to a few lines rather than a few hundred. There should be no functional difference. BUG=None TEST=ran setup_board with and w/out -x to create x86-generic to check result Change-Id: I1e598cc4a38e9f217f2f670a00bd676bf70c2338 Reviewed-on: http://gerrit.chromium.org/gerrit/5804 Reviewed-by: Gaurav Shah Tested-by: Mike Frysinger --- common.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common.sh b/common.sh index 476043e133..af7cd92a13 100644 --- a/common.sh +++ b/common.sh @@ -220,18 +220,20 @@ FACTORY_INSTALL_MASK=" " # Determine and set up variables needed for fancy color output (if supported). -V_REVERSE= -V_VIDOFF= V_BOLD_RED= V_BOLD_GREEN= V_BOLD_YELLOW= +V_REVERSE= +V_VIDOFF= if tput colors >/dev/null 2>&1; then - V_REVERSE="$(tput rev)" - V_VIDOFF="$(tput sgr0)" + # order matters: we want VIDOFF last so that when we trace with `set -x`, + # our terminal doesn't bleed colors as bash dumps the values of vars. V_BOLD_RED="$(tput bold; tput setaf 1)" V_BOLD_GREEN="$(tput bold; tput setaf 2)" V_BOLD_YELLOW="$(tput bold; tput setaf 3)" + V_REVERSE="$(tput rev)" + V_VIDOFF="$(tput sgr0)" fi # -----------------------------------------------------------------------------