All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	xen-devel@lists.xensource.com
Cc: george.dunlap@citrix.com
Subject: Re: [PATCH 1/5] raisin: introduce _verbose_echo
Date: Tue, 21 Apr 2015 16:09:08 +0100	[thread overview]
Message-ID: <55366814.2000700@eu.citrix.com> (raw)
In-Reply-To: <1429628103-10979-1-git-send-email-stefano.stabellini@eu.citrix.com>

On 04/21/2015 03:54 PM, Stefano Stabellini wrote:
> A new utility function to make the code more readable and compact:
> prints a message if VERBOSE = 1.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  lib/common-functions.sh |   46 ++++++++++++++++------------------------------
>  1 file changed, 16 insertions(+), 30 deletions(-)
> 
> diff --git a/lib/common-functions.sh b/lib/common-functions.sh
> index dc3a2bb..c19046b 100644
> --- a/lib/common-functions.sh
> +++ b/lib/common-functions.sh
> @@ -1,5 +1,12 @@
>  #!/usr/bin/env bash
>  
> +function _verbose_echo() {
> +    if [[ $VERBOSE -eq 1 ]]
> +    then
> +        echo $*
> +    fi
> +}

Why _?  Don't we have VERBOSE in other parts of the code that could call
this?

 -George

> +
>  # Executed once at the beginning of the script
>  function common_init() {
>      export BASEDIR=`pwd`
> @@ -33,12 +40,9 @@ function common_init() {
>      get_arch
>      get_components
>  
> -    if [[ $VERBOSE -eq 1 ]]
> -    then
> -        echo "Distro: $DISTRO"
> -        echo "Arch: $ARCH"
> -        echo "Components: $COMPONENTS"
> -    fi
> +    _verbose_echo "Distro: $DISTRO"
> +    _verbose_echo "Arch: $ARCH"
> +    _verbose_echo "Components: $COMPONENTS"
>  
>      for f in $COMPONENTS
>      do
> @@ -62,10 +66,7 @@ function get_components() {
>              if eval [[ ! -z \$"$capital"_REVISION ]]
>              then
>                  COMPONENTS="$COMPONENTS $component"
> -                if [[ $VERBOSE -eq 1 ]]
> -                then
> -                    echo "Found component $component"
> -                fi
> +                _verbose_echo "Found component $component"
>              fi
>          done
>      fi
> @@ -166,10 +167,7 @@ function get_arch() {
>  }
>  
>  function _check-package-deb() {
> -    if [[ $VERBOSE -eq 1 ]]
> -    then
> -        echo "Checking for package ${args[0]}"
> -    fi
> +    _verbose_echo "Checking for package ${args[0]}"
>  
>      if dpkg -s "$1" 2>/dev/null | grep -q "Status:.*installed"
>      then
> @@ -184,10 +182,7 @@ function _install-package-deb() {
>  }
>  
>  function _check-package-rpm() {
> -    if [[ $VERBOSE -eq 1 ]]
> -    then
> -        echo "Checking for package $1"
> -    fi
> +    _verbose_echo "Checking for package $1"
>  
>      if rpm -q "$1" 2>&1 >/dev/null
>      then
> @@ -273,22 +268,13 @@ function for_each_component () {
>          done
>          if [[ $found -eq 0 ]]
>          then
> -            if [[ $VERBOSE -eq 1 ]]
> -            then
> -                echo "$component" is disabled
> -            fi
> +            _verbose_echo "$component" is disabled
>              continue
>          fi
>  
> -        if [[ $VERBOSE -eq 1 ]]
> -        then
> -            echo calling "$component"_"$1"
> -        fi
> +        _verbose_echo calling "$component"_"$1"
>          "$component"_"$1"
> -        if [[ $VERBOSE -eq 1 ]]
> -        then
> -            echo "$component"_"$1" done
> -        fi
> +        _verbose_echo "$component"_"$1" done
>      done
>  }
>  
> 

  reply	other threads:[~2015-04-21 15:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 14:54 [PATCH 0/5] raisin: introduce ovmf and linux Stefano Stabellini
2015-04-21 14:54 ` [PATCH 1/5] raisin: introduce _verbose_echo Stefano Stabellini
2015-04-21 15:09   ` George Dunlap [this message]
2015-04-21 15:37     ` Stefano Stabellini
2015-04-21 14:55 ` [PATCH 2/5] raisin: remove duplicate source config in raise Stefano Stabellini
2015-04-21 15:09   ` George Dunlap
2015-04-21 15:42     ` Stefano Stabellini
2015-04-21 14:55 ` [PATCH 3/5] raisin: rename ARCH to RAISIN_ARCH Stefano Stabellini
2015-04-21 15:09   ` George Dunlap
2015-04-21 14:55 ` [PATCH 4/5] raisin: introduce ovmf Stefano Stabellini
2015-04-21 15:03   ` George Dunlap
2015-04-21 15:43     ` Stefano Stabellini
2015-04-21 15:45       ` George Dunlap
2015-04-21 15:46         ` George Dunlap
2015-04-21 14:55 ` [PATCH 5/5] raisin: build linux Stefano Stabellini
2015-04-21 15:11   ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55366814.2000700@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.