Re: [libvirt] [PATCH 2/2] virt-aa-helper-test: avoid non-portable echo -n

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric Blake wrote:
> * tests/virt-aa-helper-test (testme): Use printf instead.
> ---
>  tests/virt-aa-helper-test |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test
> index 3a2e74b..910c438 100755
> --- a/tests/virt-aa-helper-test
> +++ b/tests/virt-aa-helper-test
> @@ -112,10 +112,10 @@ testme() {
>          fi
>      fi
>
> -    echo -n "  $outstr: " >$output
> -    echo -n " '$extra_args $args" >$output
> +    printf "  $outstr: " >$output
> +    printf " '$extra_args $args" >$output

These are fine if you know that the printf arguments
never (and will never) contain the likes of "%" and "\".
If you add a "%s" argument, then we don't even have to think about it:

       printf %s "  $outstr: " >$output
       printf %s " '$extra_args $args" >$output

>      if [ -n "$input" ]; then
> -        echo -n " < $input" >$output
> +        printf " < $input" >$output
>      fi
>      echo "': " >$output
>      set +e
> @@ -131,7 +131,7 @@ testme() {
>      else
>          echo "FAIL: exited with '$rc'" >$output
>          echo "FAIL: exited with '$rc'"
> -        echo -n "  $outstr: "
> +        printf "  $outstr: "
>          echo " '$extra_args $args': "
>          errors=$(($errors + 1))
>          #exit $rc

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]