On 06/21/2018 06:07 PM, Pádraig Brady wrote:
> On 20/06/18 23:18, Bernhard Voelker wrote:
>> BTW: setting USE_GDB=0 unveils:
>>
>>   ./tests/rm/r-root.sh: line 222: test: =: unary operator expected
>>
>> The variable 'fail' should be initialized:
>>
>>   test $fail = 1 && { cat out; cat err; Exit $fail; }
>>
>> ... *BUT* it seems that we have more cases like that:
>>
>>   $ grep -F 'unary operator expected' tests/*/*.log | sort -u | wc -l
>>   15
>>
>> Maybe we should initialize 'fail' in a central place?
> 
> Hrm maybe. We should at least s/\$fail/"$fail"/.

Currently, the use of `test $fail ...` vs. `test "$fail" ...` is 50:50.
IMO it's easier and safer to initialize fail=0 - the attached does it.

Have a nice day,
Berny
>From a6f2dd040066790f40319174cd5e86a6d16cc06c Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Fri, 22 Jun 2018 00:29:00 +0200
Subject: [PATCH] tests: initialize fail=0 to avoid "unary operator expected"
 errors

With an uninitialized variable 'fail', the unquoted use like
  test $fail = 1
lead to the shell error
  "unary operator expected".

* tests/local.mk (TESTS_ENVIRONMENT): Initialize fail=0.
---
 tests/local.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/local.mk b/tests/local.mk
index e13a6aad5..307ade920 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -66,6 +66,7 @@ TESTS_ENVIRONMENT =				\
   abs_top_srcdir='$(abs_top_srcdir)'		\
   abs_srcdir='$(abs_srcdir)'			\
   built_programs='$(built_programs) $(single_binary_progs)' \
+  fail=0					\
   host_os=$(host_os)				\
   host_triplet='$(host_triplet)'		\
   srcdir='$(srcdir)'				\
-- 
2.17.1

Reply via email to