diff mbox series

[1/3] t4216: avoid unnecessary subshell in test_bloom_filters_not_used

Message ID 20200520034444.47932-2-carenas@gmail.com (mailing list archive)
State New, archived
Headers show
Series openbsd: fixes for 2.27.0-RC0 | expand

Commit Message

Carlo Marcelo Arenas Belón May 20, 2020, 3:44 a.m. UTC
Seems to trigger a bug in at least OpenBSD's 6.7 sh where it is
interpreted as a history lookup and therefore fails 125-126, 128,
130.

Remove the subshell and get a space between ! and grep, so tests
pass successfully.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 t/t4216-log-bloom.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano May 20, 2020, 3:04 p.m. UTC | #1
Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:

> Seems to trigger a bug in at least OpenBSD's 6.7 sh where it is
> interpreted as a history lookup and therefore fails 125-126, 128,
> 130.
>
> Remove the subshell and get a space between ! and grep, so tests
> pass successfully.

It's strange that somebody thinks of doing history lookup in
non-interactive use.

But even more curious is why we have this in a subshell in the first
place.  I do not see a reason why we need subshell, nor use of the
double-quote in the outer layer that forces us to use backslashes.

>  test_bloom_filters_not_used () {
>  	log_args=$1
>  	setup "$log_args" &&
> -	!(grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf") &&
> +	! grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf" &&

This is obviously the minimum fix, so I'm willing to take the change
as-is, but if we were writing it today, perhaps

	! grep 'statistics:{"filter_not_present":' "$TRASH_DIRECTORY/trace.perf" &&

is how we write it.  I do not see any reason why we want to use the
"-q" option either.
diff mbox series

Patch

diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index 21b68dd6c8..c855bcd3e7 100755
--- a/t/t4216-log-bloom.sh
+++ b/t/t4216-log-bloom.sh
@@ -70,7 +70,7 @@  test_bloom_filters_used () {
 test_bloom_filters_not_used () {
 	log_args=$1
 	setup "$log_args" &&
-	!(grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf") &&
+	! grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf" &&
 	test_cmp log_wo_bloom log_w_bloom
 }