[PATCH openbmc v6 09/18] initfs: update: Consistently add ERROR: and print to stderr

Andrew Jeffery andrew at aj.id.au
Thu Jun 23 15:08:41 AEST 2016


On Wed, 2016-06-22 at 19:30 -0500, OpenBMC Patches wrote:
> From: Milton Miller <miltonm at us.ibm.com>
> 
> Make sure all error messages start with the tag ERROR.  Also redirect
> output to stderr (once case had the file descriptors backwards).

Maybe we should lift the calls out to a shell function, something like:

print_err() {
	echo 1>&2 ERROR: $@
}

> 
> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> ---
>  .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh    | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> index f0ca989..4249161 100755
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
> @@ -21,7 +21,7 @@ fi
>  
>  if grep mtd /proc/mounts
>  then
> -	echo 1>&2 "Error: A mtd device is mounted."
> +	echo 1>&2 "ERROR: A mtd device is mounted."
>  	exit 1
>  fi
>  
> @@ -65,6 +65,8 @@ toram=
>  whitelist=/run/initramfs/whitelist
>  image=/run/initramfs/image-
>  
> +E="ERROR:"

I'd prefer the function approach, but if we're going to do this
instead, lets at least do it at the top of the script so we can use the
same approach in the hunk above.

> +
>  while test "$1" != "${1#-}"
>  do
>  	case "$1" in
> @@ -90,7 +92,7 @@ do
>  		toram=y
>  		shift ;;
>  	*)
> -		echo 2>&1 "Unknown option $1"
> +		echo 1>&2 "$E Unknown option $1"
>  		exit 1 ;;
>  	esac
>  done
> @@ -126,7 +128,7 @@ do
>  	m=$(findmtd ${f#$image})
>  	if test -z "$m"
>  	then
> -		echo 1>&2  "Unable to find mtd partiton for ${f##*/}."
> +		echo 1>&2 "$E Unable to find mtd partiton for ${f##*/}."
>  		exit 1
>  	fi
>  done
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160623/109925f0/attachment.sig>


More information about the openbmc mailing list