[libvirt] [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"

Daniel Veillard veillard at redhat.com
Wed Apr 14 11:55:06 UTC 2010


On Wed, Apr 14, 2010 at 01:28:54PM +0200, Jim Meyering wrote:
> echo -e is not portable.
> This is the sole remaining use in all of libvirt.
> 
> >From a58cf340b5ebbca2157f43c6f23d4d6f56b848c7 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Wed, 14 Apr 2010 13:25:46 +0200
> Subject: [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"
> 
> * tests/schematestutils.sh: Use printf rather than echo -e.
> ---
>  tests/schematestutils.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
> index f172857..f2b3b50 100644
> --- a/tests/schematestutils.sh
> +++ b/tests/schematestutils.sh
> @@ -22,7 +22,7 @@ do
> 
>      test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret
>      if test "$verbose" = "1" && test $ret != 0 ; then
> -        echo -e "$cmd\n$result"
> +        printf '%s\n' "$cmd" "$result"
>      fi
>      if test "$ret" != 0 ; then
>          f=`expr $f + 1`

  I fail to see how printf(1) is any more portable than echo which
is usually from the shell itself. Sounds to me that
     echo "$cmd" ; echo "$result"
does what we want directly or am I mistaken ?

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list