On Tue, Sep 23, 2014 at 05:20:36PM +0800, Hu Tao wrote:
# 0, 2 and 3 are reasonable non-error exit codes. Others are
errors.
-if [ $r -ne 0 -a $r -ne 2 -a $r -ne 3 ]; then
+if [ $r -ne 0 && $r -ne 2 && $r -ne 3 ]; then
I think the intention of this test is that you're supposed to do:
if [ $r -ne 0 ] && [ $r -ne 2 ] ....
Note that && doesn't work as a test operator:
$ test a = b -a c = d
$ test a = b '&&' c = d
bash: test: too many arguments
Rich.
> exit $r
> fi
> diff --git a/align/test-virt-alignment-scan.sh b/align/test-virt-alignment-scan.sh
> index 293a9ef..7f02ba9 100755
> --- a/align/test-virt-alignment-scan.sh
> +++ b/align/test-virt-alignment-scan.sh
> @@ -22,6 +22,6 @@ $VG virt-alignment-scan -a ../tests/guests/fedora.img
> r=$?
>
# 0, 2 and 3 are reasonable non-error exit codes. Others are
errors.
-if [ $r -ne 0 -a $r -ne 2 -a $r -ne 3 ]; then
+if [ $r -ne 0 && $r -ne 2 && $r -ne 3 ]; then
> exit $r
> fi
> diff --git a/builder/test-virt-builder-planner.sh
b/builder/test-virt-builder-planner.sh
> index f974c27..adf461e 100755
> --- a/builder/test-virt-builder-planner.sh
> +++ b/builder/test-virt-builder-planner.sh
> @@ -24,7 +24,7 @@ abs_builddir=$(pwd)
> export XDG_CONFIG_HOME=
> export XDG_CONFIG_DIRS="$abs_builddir/test-config"
>
> -if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
> +if [ ! -f fedora.xz || ! -f fedora.qcow2 || ! -f fedora.qcow2.xz ]; then
> echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or
fedora.qcow2.xz in the build directory"
> exit 77
> fi
> diff --git a/builder/website/ubuntu.sh b/builder/website/ubuntu.sh
> index 0863fb0..16cf91f 100755
> --- a/builder/website/ubuntu.sh
> +++ b/builder/website/ubuntu.sh
> @@ -26,7 +26,7 @@ export LANG=C
> set -e
> set -x
>
> -if [ $# -lt 2 -o $# -gt 3 ]; then
> +if [ $# -lt 2 || $# -gt 3 ]; then
> echo "$0 VERSION DIST [OSVARIANT]"
> exit 1
> fi
> diff --git a/configure.ac b/configure.ac
> index 9578b59..47272fe 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1531,7 +1531,7 @@ AS_IF([test "x$enable_gobject" != "xno"],[
> [AC_MSG_WARN([gio library not found, gobject binding will be disabled])])
> ])
> AM_CONDITIONAL([HAVE_GOBJECT],
> - [test "x$GOBJECT_LIBS" != "x" -a
"x$GIO_LIBS" != "x"])
> + [test "x$GOBJECT_LIBS" != "x" &&
"x$GIO_LIBS" != "x"])
>
> AC_CHECK_PROG([GJS],[gjs],[gjs])
> AS_IF([test "x$GJS" = "x"],
> diff --git a/fish/test-mount-local.sh b/fish/test-mount-local.sh
> index 845f707..0bc4f5d 100755
> --- a/fish/test-mount-local.sh
> +++ b/fish/test-mount-local.sh
> @@ -33,7 +33,7 @@ test -w /dev/fuse || {
>
> set -e
>
> -if [ $# -gt 0 -a "$1" = "--run-test" ]; then
> +if [ $# -gt 0 && "$1" = "--run-test" ]; then
> # Create some files and read them back.
> echo 'hello' > test-mount-local-mp/hello
> chmod 0600 test-mount-local-mp/hello
> diff --git a/make-fs/test-virt-make-fs.sh b/make-fs/test-virt-make-fs.sh
> index 2ed3ce9..067e665 100755
> --- a/make-fs/test-virt-make-fs.sh
> +++ b/make-fs/test-virt-make-fs.sh
> @@ -57,7 +57,7 @@ function random_choice
> # in the appliance fails when trying to change the UID of
> # the files to some non-zero value (not supported by FAT).
> choices=(--type=ext2 --type=ext3 --type=ext4)
> -if [ "$ntfs3g_available" = "yes" -a
"$ntfsprogs_available" = "yes" ]; then
> +if [ "$ntfs3g_available" = "yes" &&
"$ntfsprogs_available" = "yes" ]; then
> choices[${#choices[*]}]="--type=ntfs"
> fi
> if [ "$btrfs_available" = "yes" ]; then
> diff --git a/src/api-support/update-from-tarballs.sh
b/src/api-support/update-from-tarballs.sh
> index 328b11b..e2160c7 100755
> --- a/src/api-support/update-from-tarballs.sh
> +++ b/src/api-support/update-from-tarballs.sh
> @@ -36,7 +36,7 @@ for t in $tarballs; do
> # x.y.z
> v=$(echo $p | sed 's/^libguestfs-//')
>
> - if [ $v != "1.2.0" -a $v != "1.3.0" -a ! -f $v ]; then
> + if [ $v != "1.2.0" && $v != "1.3.0" && ! -f
$v ]; then
> rm -rf "$tmpdir/*"
> tar -C "$tmpdir" \
> -zxf $t $p/src/*.c 2>/dev/null ||:
> diff --git a/sysprep/test-virt-sysprep-script.sh
b/sysprep/test-virt-sysprep-script.sh
> index 10ba1d1..65813d5 100755
> --- a/sysprep/test-virt-sysprep-script.sh
> +++ b/sysprep/test-virt-sysprep-script.sh
> @@ -37,7 +37,7 @@ if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable
script \
> echo "$0: virt-sysprep wasn't expected to exit with error."
> exit 1
> fi
> -if [ ! -f stamp-script1.sh -o ! -f stamp-script2.sh ]; then
> +if [ ! -f stamp-script1.sh || ! -f stamp-script2.sh ]; then
> echo "$0: one of the two test scripts did not run."
> exit 1
> fi
> diff --git a/tests/qemu/qemu-snapshot-isolation.sh
b/tests/qemu/qemu-snapshot-isolation.sh
> index daa210f..31b3562 100755
> --- a/tests/qemu/qemu-snapshot-isolation.sh
> +++ b/tests/qemu/qemu-snapshot-isolation.sh
> @@ -98,7 +98,7 @@ fi
> if [ "$(md5sum isolation2.img | awk '{print $1}')" !=
"$isolation2_md5sum" ]; then
> serious_error
> fi
> -if [ "$supports_qcow2" = "yes" -a \
> +if [ "$supports_qcow2" = "yes" && \
> "$(md5sum isolation3.img | awk '{print $1}')" !=
"$isolation3_md5sum" ]; then
> serious_error
> fi
> diff --git a/tests/regressions/rhbz563450.sh b/tests/regressions/rhbz563450.sh
> index d7cf751..cc3591b 100755
> --- a/tests/regressions/rhbz563450.sh
> +++ b/tests/regressions/rhbz563450.sh
> @@ -22,7 +22,7 @@
> set -e
> export LANG=C
>
> -if [ ! -s ../guests/fedora.img -o ! -s ../data/test.iso -o ! -s ../guests/debian.img
]; then
> +if [ ! -s ../guests/fedora.img || ! -s ../data/test.iso || ! -s ../guests/debian.img
]; then
> echo "$0: test skipped because there is no fedora.img nor test.iso nor
debian.img"
> exit 77
> fi
> --
> 1.9.3
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs(a)redhat.com
>
https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org