From 023d51076653f308fb14f616ee559edc17dd2d3f Mon Sep 17 00:00:00 2001
From: Hallvard Furuseth <hallvard@openldap.org>
Date: Sat, 17 Sep 2005 22:22:15 +0000
Subject: [PATCH] Support POSIX 1003.1-2001 without XSI extensions (ITS #2667):
 Do not use test -a/-o.  Use shell features like &&, || or case...esac. Use
 grep instead of egrep (but not the not-yet-portable Posix variant grep -E).
 Based on a patch from Paul Eggert.

---
 build/mkdep                                   |   2 +-
 build/openldap.m4                             |  42 ++--
 configure.in                                  | 201 +++++++++---------
 contrib/ldaptcl/configure                     |   2 +-
 contrib/ldaptcl/configure.in                  |   2 +-
 servers/slapd/Makefile.in                     |   8 +-
 tests/scripts/acfilter.sh                     |   2 +-
 tests/scripts/test000-rootdse                 |   5 +-
 tests/scripts/test018-syncreplication-persist |   2 +-
 tests/scripts/test019-syncreplication-cascade |   2 +-
 tests/scripts/test036-meta-concurrency        |   2 +-
 11 files changed, 138 insertions(+), 132 deletions(-)

diff --git a/build/mkdep b/build/mkdep
index 0e8ce3d857..eec2d20de3 100755
--- a/build/mkdep
+++ b/build/mkdep
@@ -161,7 +161,7 @@ for i in $files; do
 	esac
 done
 for i in $FILES; do
-	$MKDEP_CC $MKDEP_CFLAGS $FLAGS $i | egrep '^#.*"' > $TMP.sed
+	$MKDEP_CC $MKDEP_CFLAGS $FLAGS $i | grep '^#.*"' > $TMP.sed
 awk '
 BEGIN {
 	file = "'$i'"
diff --git a/build/openldap.m4 b/build/openldap.m4
index ab2371b3d5..05170db5a9 100644
--- a/build/openldap.m4
+++ b/build/openldap.m4
@@ -80,7 +80,7 @@ if test -z "${MKDEP}"; then
  noCode;
 EOF
 				if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
-					| egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
+					| grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
 				then
 					if test ! -f conftest."${ac_object}" ; then
 						ol_cv_mkdep=$flag
@@ -500,7 +500,7 @@ dnl --------------------------------------------------------------------
 dnl Find old Berkeley DB 1.85/1.86
 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
 [AC_CHECK_HEADERS(db_185.h db.h)
-if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
+if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
 	AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
 		AC_EGREP_CPP(__db_version_1,[
 #if HAVE_DB_185_H
@@ -562,7 +562,7 @@ AC_DEFUN([OL_GDBM],
 [AC_REQUIRE([OL_LIB_GDBM])
  AC_CHECK_HEADERS(gdbm.h)
  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
-	if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
+	if test $ol_cv_lib_gdbm = no || test $ac_cv_header_gdbm_h = no ; then
 		ol_cv_gdbm=no
 	else
 		ol_cv_gdbm=yes
@@ -607,7 +607,7 @@ AC_DEFUN([OL_MDBM],
 [AC_REQUIRE([OL_LIB_MDBM])
  AC_CHECK_HEADERS(mdbm.h)
  AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
-	if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
+	if test $ol_cv_lib_mdbm = no || test $ac_cv_header_mdbm_h = no ; then
 		ol_cv_mdbm=no
 	else
 		ol_cv_mdbm=yes
@@ -663,7 +663,7 @@ AC_DEFUN([OL_NDBM],
 [AC_REQUIRE([OL_LIB_NDBM])
  AC_CHECK_HEADERS(ndbm.h)
  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
-	if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
+	if test $ol_cv_lib_ndbm = no || test $ac_cv_header_ndbm_h = no ; then
 		ol_cv_ndbm=no
 	else
 		ol_cv_ndbm=yes
@@ -894,11 +894,11 @@ AC_DEFUN([OL_LINUX_THREADS], [
 	AC_REQUIRE([OL_HEADER_LINUX_THREADS])
 	AC_REQUIRE([OL_SYS_LINUX_THREADS])
 	AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
-		if test $ol_cv_header_linux_threads = yes -a \
-			$ol_cv_sys_linux_threads = yes; then
+		if test $ol_cv_header_linux_threads = yes &&
+		   test $ol_cv_sys_linux_threads = yes; then
 			ol_cv_linux_threads=yes
-		elif test $ol_cv_header_linux_threads = no -a \
-			$ol_cv_sys_linux_threads = no; then
+		elif test $ol_cv_header_linux_threads = no &&
+		     test $ol_cv_sys_linux_threads = no; then
 			ol_cv_linux_threads=no
 		else
 			ol_cv_linux_threads=error
@@ -1089,13 +1089,13 @@ AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
 
 	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer);]])],[ol_cv_func_ctime_r_nargs2=yes],[ol_cv_func_ctime_r_nargs2=no])
 
-	if test $ol_cv_func_ctime_r_nargs3 = yes -a \
-		$ol_cv_func_ctime_r_nargs2 = no ; then
+	if test $ol_cv_func_ctime_r_nargs3 = yes &&
+	   test $ol_cv_func_ctime_r_nargs2 = no ; then
 
 		ol_cv_func_ctime_r_nargs=3
 
-	elif test $ol_cv_func_ctime_r_nargs3 = no -a \
-		$ol_cv_func_ctime_r_nargs2 = yes ; then
+	elif test $ol_cv_func_ctime_r_nargs3 = no &&
+	     test $ol_cv_func_ctime_r_nargs2 = yes ; then
 
 		ol_cv_func_ctime_r_nargs=2
 
@@ -1144,13 +1144,13 @@ AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
 		(void)gethostbyname_r("localhost", &hent, buffer, bufsize,
 			&rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
 
-	if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
-		$ol_cv_func_gethostbyname_r_nargs6 = no ; then
+	if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
+	   test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
 
 		ol_cv_func_gethostbyname_r_nargs=5
 
-	elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
-		$ol_cv_func_gethostbyname_r_nargs6 = yes ; then
+	elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
+	     test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
 
 		ol_cv_func_gethostbyname_r_nargs=6
 
@@ -1193,13 +1193,13 @@ AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
 			alen, AF_INET, &hent, buffer, bufsize, 
 			&rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
 
-	if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
-		$ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
+	if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
+	   test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
 
 		ol_cv_func_gethostbyaddr_r_nargs=7
 
-	elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
-		$ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
+	elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
+	     test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
 
 		ol_cv_func_gethostbyaddr_r_nargs=8
 
diff --git a/configure.in b/configure.in
index d1ef9c248c..44b15b56d7 100644
--- a/configure.in
+++ b/configure.in
@@ -40,7 +40,7 @@ if test -z "$OL_STRING"; then
 	AC_MSG_ERROR([could not determine version])
 fi
 
-if test -f "$ac_aux_dir/shtool" -a ! -d $ac_aux_dir/shtool; then
+if test -f "$ac_aux_dir/shtool" && test ! -d $ac_aux_dir/shtool; then
 	ac_cv_shtool="$ac_aux_dir/shtool"
 else
 	AC_MSG_ERROR([no shtool found in $ac_aux_dir])
@@ -483,19 +483,19 @@ elif test $ol_enable_ldbm = no ; then
 		AC_MSG_WARN([LDBM disabled, ignoring --enable-ldbm-type argument])
 	fi
 
-	if test $ol_enable_modules != yes -a \
-		$ol_enable_bdb = no -a \
-		$ol_enable_dnssrv = no -a \
-		$ol_enable_hdb = no -a \
-		$ol_enable_ldap = no -a \
-		$ol_enable_meta = no -a \
-		$ol_enable_monitor = no -a \
-		$ol_enable_null = no -a \
-		$ol_enable_passwd = no -a \
-		$ol_enable_perl = no -a \
-		$ol_enable_relay = no -a \
-		$ol_enable_shell = no -a \
-		$ol_enable_sql = no ; then
+	if test $ol_enable_modules != yes &&
+	   test $ol_enable_bdb = no &&
+	   test $ol_enable_dnssrv = no &&
+	   test $ol_enable_hdb = no &&
+	   test $ol_enable_ldap = no &&
+	   test $ol_enable_meta = no &&
+	   test $ol_enable_monitor = no &&
+	   test $ol_enable_null = no &&
+	   test $ol_enable_passwd = no &&
+	   test $ol_enable_perl = no &&
+	   test $ol_enable_relay = no &&
+	   test $ol_enable_shell = no &&
+	   test $ol_enable_sql = no ; then
 
 		if test $ol_enable_slapd = yes ; then
 			AC_MSG_ERROR([slapd requires a backend])
@@ -508,26 +508,26 @@ elif test $ol_enable_ldbm = no ; then
 	ol_enable_ldbm_api=no
 	ol_enable_ldbm_type=no
 
-	if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then
+	if test $ol_enable_bdb/$ol_enable_hdb != no/no; then
 		ol_enable_ldbm_api=berkeley
 	fi
 
 else
 	dnl SLAPD with LDBM
-	if test $ol_enable_ldbm_api = gdbm -a \
-		$ol_enable_ldbm_type = btree ; then
+	if test $ol_enable_ldbm_api = gdbm &&
+	   test $ol_enable_ldbm_type = btree ; then
 		AC_MSG_ERROR([GDBM only supports LDBM type hash])
 	fi
-	if test $ol_enable_ldbm_api = mdbm -a \
-		$ol_enable_ldbm_type = btree ; then
+	if test $ol_enable_ldbm_api = mdbm &&
+	   test $ol_enable_ldbm_type = btree ; then
 		AC_MSG_ERROR([MDBM only supports LDBM type hash])
 	fi
-	if test $ol_enable_ldbm_api = ndbm -a \
-		$ol_enable_ldbm_type = btree ; then
+	if test $ol_enable_ldbm_api = ndbm &&
+	   test $ol_enable_ldbm_type = btree ; then
 		AC_MSG_ERROR([NDBM only supports LDBM type hash])
 	fi
 
-	if test $ol_enable_bdb != no -o $ol_enable_hdb != no ; then
+	if test $ol_enable_bdb/$ol_enable_hdb != no/no ; then
 		if test $ol_enable_ldbm_api = auto ; then
 			ol_enable_ldbm_api=berkeley
 		elif test $ol_enable_ldbm_api != berkeley ; then
@@ -536,7 +536,7 @@ else
 	fi
 fi
 
-if test $ol_enable_meta = yes -a $ol_enable_ldap = no ; then
+if test $ol_enable_meta/$ol_enable_ldap = yes/no ; then
 	AC_MSG_ERROR([--enable-meta requires --enable-ldap])
 fi
 
@@ -700,10 +700,11 @@ if test $ol_aix_threads = yes ; then
   		fi
 	fi
 
-	if test "${CC}" = "cc_r" -o "${CC}" = "xlc_r" ; then
+	case ${CC} in cc_r | xlc_r)
 		ol_with_threads=posix
 		ol_cv_pthread_create=yes
-	fi
+		;;
+	esac
 fi
 
 if test -z "${CC}"; then
@@ -1078,7 +1079,7 @@ if test "$ol_cv_lib_resolver" != no ; then
 	fi
 fi
 
-if test "$ol_enable_dnssrv" = yes -o "$ol_enable_dnssrv" = mod ; then
+if test "$ol_enable_dnssrv" = yes || test "$ol_enable_dnssrv" = mod ; then
 	if test "$ol_link_dnssrv" = no ; then
 		AC_MSG_ERROR([DNSSRV requires res_query()])
 	fi
@@ -1094,7 +1095,7 @@ dnl PF_LOCAL may use getaddrinfo in available
 AC_CHECK_FUNCS( getaddrinfo getnameinfo gai_strerror inet_ntop )
 
 ol_link_ipv6=no
-if test $ac_cv_func_getaddrinfo = no -o $ac_cv_func_inet_ntop = no ; then
+if test $ac_cv_func_getaddrinfo = no || test $ac_cv_func_inet_ntop = no ; then
 	if test $ol_enable_ipv6 = yes ; then
 		AC_MSG_ERROR([IPv6 support requires getaddrinfo() and inet_ntop()])
 	fi
@@ -1116,14 +1117,14 @@ elif test $ol_enable_ipv6 != no ; then
 			struct sockaddr_storage ss;
 ]])],[ol_cv_struct_sockaddr_storage=yes],[ol_cv_struct_sockaddr_storage=no])])
 
-	if test $ol_cv_inet6_addrstrlen = yes \
-		-a $ol_cv_struct_sockaddr_storage = yes ; then
+	if test $ol_cv_inet6_addrstrlen = yes &&
+	   test $ol_cv_struct_sockaddr_storage = yes ; then
 		ol_link_ipv6=yes
-	elif test $ol_enable_ipv6 = yes \
-			-a $ol_cv_inet6_addrstrlen = no ; then
+	elif test $ol_enable_ipv6 = yes &&
+	     test $ol_cv_inet6_addrstrlen = no ; then
 		AC_MSG_ERROR([IPv6 support requires INET6_ADDRSTRLEN])
-	elif test $ol_enable_ipv6 = yes \
-			-a $ol_cv_struct_sockaddr_storage = no ; then
+	elif test $ol_enable_ipv6 = yes &&
+	     test $ol_cv_struct_sockaddr_storage = no ; then
 		AC_MSG_ERROR([IPv6 support requires struct sockaddr_storage])
 	fi
 fi
@@ -1144,9 +1145,7 @@ ol_link_kbind=no
 ol_link_krb5=no
 ol_link_krb4=no
 
-if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
-	-o $ol_with_kerberos = k5 -o $ol_with_kerberos = k5only \
-	-o $ol_with_kerberos = k425 ; then
+case $ol_with_kerberos in yes | auto | k5 | k5only | k425)
 
 	AC_CHECK_HEADERS(krb5.h)
 
@@ -1204,10 +1203,13 @@ if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
 		fi
 
 	fi
-fi
+	;;
+esac
 
-if test $ol_link_krb5 = yes -a \( $ol_with_kerberos = yes -o \
-	$ol_with_kerberos = auto -o $ol_with_kerberos = k425 \) ; then
+if test $ol_link_krb5 = yes &&
+   { test $ol_with_kerberos = yes ||
+     test $ol_with_kerberos = auto ||
+     test $ol_with_kerberos = k425; }; then
 
 	AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)
 
@@ -1266,8 +1268,7 @@ if test $ol_link_krb5 = yes ; then
 	ol_with_kerberos=found
 fi
 
-if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
-	-o $ol_with_kerberos = k4 -o $ol_with_kerberos = kth ; then
+case $ol_with_kerberos in yes | auto | k4 | kth)
 
 	AC_CHECK_HEADERS(krb.h des.h krb-archaeology.h )
 
@@ -1289,19 +1290,20 @@ if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
 			fi
 		fi
 	fi
-fi
+	;;
+esac
 
-if test $ol_link_krb4 = yes -a $ol_enable_kbind != no ; then
+if test $ol_link_krb4 = yes && test $ol_enable_kbind != no ; then
 	ol_link_kbind=yes
 
 elif test $ol_enable_kbind = yes ; then
 	AC_MSG_ERROR([Kerberos IV detection failed])
 fi
 
-if test $ol_link_krb4 = yes -o $ol_link_krb5 = yes ; then
+if test $ol_link_krb4 = yes || test $ol_link_krb5 = yes ; then
 	AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
 
-elif test $ol_with_kerberos != auto -a $ol_with_kerberos != no ; then
+elif test $ol_with_kerberos != auto && test $ol_with_kerberos != no ; then
 	AC_MSG_ERROR([Kerberos detection failed])
 fi
 
@@ -1312,8 +1314,8 @@ ol_link_tls=no
 if test $ol_with_tls != no ; then
 	AC_CHECK_HEADERS(openssl/ssl.h ssl.h)
 
-	if test $ac_cv_header_openssl_ssl_h = yes \
-		-o $ac_cv_header_ssl_h = yes ; then
+	if test $ac_cv_header_openssl_ssl_h = yes ||
+	   test $ac_cv_header_ssl_h = yes ; then
 		AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, 
 			[have_ssleay=yes
 			need_rsaref=no],
@@ -1390,8 +1392,7 @@ dnl ----------------------------------------------------------------
 dnl Threads?
 ol_link_threads=no
 
-if test $ol_with_threads = auto -o $ol_with_threads = yes \
-	-o $ol_with_threads = nt ; then
+case $ol_with_threads in auto | yes | nt)
 
 	OL_NT_THREADS
 
@@ -1407,10 +1408,10 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 	if test $ol_with_threads = nt ; then
 		AC_MSG_ERROR([could not locate NT Threads])
 	fi
-fi
+	;;
+esac
 
-if test $ol_with_threads = auto -o $ol_with_threads = yes \
-	-o $ol_with_threads = posix ; then
+case $ol_with_threads in auto | yes | posix)
 
 	AC_CHECK_HEADERS(pthread.h)
 
@@ -1526,9 +1527,9 @@ dnl			[ol_cv_pthread_lpthread_lexc])
 			dnl check for both, and thr_yield for Solaris
 			AC_CHECK_FUNCS(sched_yield pthread_yield thr_yield)
 
-			if test $ac_cv_func_sched_yield = no -a \
-				$ac_cv_func_pthread_yield = no -a \
-				$ac_cv_func_thr_yield = no ; then
+			if test $ac_cv_func_sched_yield = no &&
+			   test $ac_cv_func_pthread_yield = no &&
+			   test $ac_cv_func_thr_yield = no ; then
 				dnl Digital UNIX has sched_yield() in -lrt
 				AC_CHECK_LIB(rt, sched_yield,
 					[LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
@@ -1537,9 +1538,9 @@ dnl			[ol_cv_pthread_lpthread_lexc])
 					ac_cv_func_sched_yield=yes],
 					[ac_cv_func_sched_yield=no])
 			fi
-			if test $ac_cv_func_sched_yield = no -a \
-				$ac_cv_func_pthread_yield = no -a \
-				"$ac_cv_func_thr_yield" = no ; then
+			if test $ac_cv_func_sched_yield = no &&
+			   test $ac_cv_func_pthread_yield = no &&
+			   test "$ac_cv_func_thr_yield" = no ; then
 				AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
 			fi
 
@@ -1692,10 +1693,10 @@ int main(argc, argv)
 	if test $ol_with_threads = posix ; then
 		AC_MSG_ERROR([could not locate POSIX Threads])
 	fi
-fi
+	;;
+esac
 
-if test $ol_with_threads = auto -o $ol_with_threads = yes \
-	-o $ol_with_threads = mach ; then
+case $ol_with_threads in auto | yes | mach)
 
 	dnl check for Mach CThreads
 	AC_CHECK_HEADERS(mach/cthreads.h cthreads.h)
@@ -1757,10 +1758,10 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 	elif test $ol_with_threads = found ; then
 		AC_MSG_ERROR([could not link with Mach CThreads])
 	fi
-fi
+	;;
+esac
 
-if test $ol_with_threads = auto -o $ol_with_threads = yes \
-	-o $ol_with_threads = pth ; then
+case $ol_with_threads in auto | yes | pth)
 
 	AC_CHECK_HEADERS(pth.h)
 
@@ -1778,14 +1779,15 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 			fi
 		fi
 	fi
-fi
+	;;
+esac
 
-if test $ol_with_threads = auto -o $ol_with_threads = yes \
-	-o $ol_with_threads = lwp ; then
+case $ol_with_threads in auto | yes | lwp)
 
 	dnl check for SunOS5 LWP
 	AC_CHECK_HEADERS(thread.h synch.h)
-	if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
+	if test $ac_cv_header_thread_h = yes &&
+	   test $ac_cv_header_synch_h = yes ; then
 		AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
 
 		if test $have_thr = yes ; then
@@ -1822,7 +1824,8 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
 			fi
 		fi
 	fi
-fi
+	;;
+esac
 
 if test $ol_with_yielding_select = yes ; then
 	AC_DEFINE(HAVE_YIELDING_SELECT,1,
@@ -1844,7 +1847,7 @@ if test $ol_with_threads = manual ; then
 	AC_CHECK_HEADERS(thread.h synch.h)
 fi
 
-if test $ol_link_threads != no -a $ol_link_threads != nt ; then  
+if test $ol_link_threads != no && test $ol_link_threads != nt ; then
 	dnl needed to get reentrant/threadsafe versions
 	dnl
 	AC_DEFINE(REENTRANT,1)
@@ -1869,8 +1872,8 @@ if test $ol_link_threads != no -a $ol_link_threads != nt ; then
 		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[h_errno = 0;]])],[ol_cv_h_errno_thread_specific=yes],[ol_cv_h_errno_thread_specific=no])
 	])
 
-	if test $ol_cv_errno_thread_specific != yes \
-		-o $ol_cv_h_errno_thread_specific != yes ; then
+	if test $ol_cv_errno_thread_specific != yes ||
+	   test $ol_cv_h_errno_thread_specific != yes ; then
 		LIBS="$LTHREAD_LIBS $LIBS"
 		LTHREAD_LIBS=""
 	fi
@@ -1975,9 +1978,7 @@ fi
 dnl ----------------------------------------------------------------
 ol_link_ldbm=no 
 
-if test $ol_enable_ldbm_api = auto \
-	-o $ol_enable_ldbm_api = berkeley \
-	-o $ol_enable_ldbm_api = bcompat ; then
+case $ol_enable_ldbm_api in auto | berkeley | bcompat)
 
 	if test $ol_enable_ldbm_api = bcompat; then \
 		OL_BERKELEY_COMPAT_DB
@@ -2006,9 +2007,10 @@ if test $ol_enable_ldbm_api = auto \
 			LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
 		fi
 	fi
-fi
+	;;
+esac
 
-if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then
+if test $ol_enable_bdb/$ol_enable_hdb != no/no; then
 	if test $ol_link_ldbm != berkeley ; then
 		AC_MSG_ERROR(BDB/HDB: BerkeleyDB not available)
 	else
@@ -2020,12 +2022,12 @@ if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then
 	fi
 fi
 
-if test $ol_link_ldbm = no -a $ol_enable_ldbm_type = btree ; then
+if test $ol_link_ldbm = no && test $ol_enable_ldbm_type = btree ; then
 	AC_MSG_WARN([Could not find LDBM with BTREE support])
 	ol_enable_ldbm_api=none
 fi
 
-if test $ol_enable_ldbm_api = auto -o $ol_enable_ldbm_api = mdbm ; then
+if test $ol_enable_ldbm_api = auto || test $ol_enable_ldbm_api = mdbm ; then
 	OL_MDBM
 
 	if test $ol_cv_mdbm = yes ; then
@@ -2037,7 +2039,7 @@ if test $ol_enable_ldbm_api = auto -o $ol_enable_ldbm_api = mdbm ; then
 	fi
 fi
 
-if test $ol_enable_ldbm_api = auto -o $ol_enable_ldbm_api = gdbm ; then
+if test $ol_enable_ldbm_api = auto || test $ol_enable_ldbm_api = gdbm ; then
 	OL_GDBM
 
 	if test $ol_cv_gdbm = yes ; then
@@ -2063,19 +2065,19 @@ if test $ol_enable_ldbm_api = ndbm ; then
 	fi
 fi
 
-if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
+if test $ol_link_ldbm = no && test $ol_enable_ldbm != no ; then
 	AC_MSG_ERROR([could not find suitable LDBM backend])
 fi
 
-if test $ol_enable_bdb = yes -o \
-	$ol_enable_hdb = yes -o \
-	$ol_enable_ldbm = yes ; then
+if test $ol_enable_bdb = yes ||
+   test $ol_enable_hdb = yes ||
+   test $ol_enable_ldbm = yes ; then
 	SLAPD_LIBS="$SLAPD_LIBS \$(LDBM_LIBS)"
 fi
 
 dnl ----------------------------------------------------------------
 
-if test $ol_enable_dynamic = yes -a $enable_shared = yes ; then
+if test $ol_enable_dynamic = yes && test $enable_shared = yes ; then
 	BUILD_LIBS_DYNAMIC=shared
 	AC_DEFINE(LDAP_LIBS_DYNAMIC, 1, [define if LDAP libs are dynamic])
 	LTSTATIC=""
@@ -2133,7 +2135,7 @@ fi
 dnl ----------------------------------------------------------------
 if test $ol_enable_syslog != no ; then
 	AC_CHECK_FUNC(openlog)
-	if test $ac_cv_func_openlog = no -a $ol_enable_syslog = yes; then
+	if test $ac_cv_func_openlog = no && test $ol_enable_syslog = yes; then
 		AC_MSG_ERROR(could not find syslog, select appropriate options or disable)
 	fi
 	ol_enable_syslog=$ac_cv_func_openlog
@@ -2180,7 +2182,8 @@ ol_link_spasswd=no
 if test $ol_with_cyrus_sasl != no ; then
 	AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
 
-	if test $ac_cv_header_sasl_sasl_h = yes -o $ac_cv_header_sasl_h = yes; then
+	if test $ac_cv_header_sasl_sasl_h = yes ||
+	   test $ac_cv_header_sasl_h = yes; then
 		AC_CHECK_LIB(sasl2, sasl_client_init,
 			[ol_link_sasl="-lsasl2"],
 			[AC_CHECK_LIB(sasl, sasl_client_init,
@@ -2228,7 +2231,7 @@ fi
 
 dnl ----------------------------------------------------------------
 dnl Check for entropy sources
-if test $cross_compiling != yes -a "$ac_cv_mingw32" != yes ; then
+if test $cross_compiling != yes && test "$ac_cv_mingw32" != yes ; then
 	dev=no
 	if test -r /dev/urandom ; then
 		dev="/dev/urandom";
@@ -2339,18 +2342,18 @@ if test "$ol_with_multiple_precision" != "no" ; then
 		ol_have_bn_h=no
 		ol_have_crypto_h=no
 
-		if test "$ac_cv_header_openssl_bn_h" = "yes" \
-				-o "$ac_cv_header_bn_h" = "yes" ; then
+		if test "$ac_cv_header_openssl_bn_h" = "yes" ||
+		   test "$ac_cv_header_bn_h" = "yes" ; then
 			ol_have_bn_h=yes
 		fi
 
-		if test "$ac_cv_header_openssl_crypto_h" = "yes" \
-				-o "$ac_cv_header_crypto_h" = "yes" ; then
+		if test "$ac_cv_header_openssl_crypto_h" = "yes" ||
+		   test "$ac_cv_header_crypto_h" = "yes" ; then
 			ol_have_crypto_h=yes
 		fi
 
-		if test "$ol_have_bn_h" = "yes" \
-				-a "$ol_have_crypto_h" = "yes" ; then
+		if test "$ol_have_bn_h" = "yes" &&
+		   test "$ol_have_crypto_h" = "yes" ; then
 			ol_have_bignum=yes
 		fi
 	fi
@@ -2595,7 +2598,8 @@ if test "$ac_cv_func_getpeereid" != yes; then
 	fi
 	LIBSRCS="$LIBSRCS getpeereid.c"
 fi
-if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
+if test "$ac_cv_func_snprintf" != yes ||
+   test "$ac_cv_func_vsnprintf" != yes; then
 	if test "$ac_cv_func_snprintf" != yes; then
 		AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
 	fi
@@ -2734,7 +2738,7 @@ if test "$ol_enable_ldap" != no ; then
 	AC_DEFINE_UNQUOTED(SLAPD_LDAP,$MFLAG,[define to support LDAP backend])
 fi
 
-if test "$ol_link_ldbm" != no -a $ol_enable_ldbm != no; then
+if test "$ol_link_ldbm" != no && test $ol_enable_ldbm != no; then
 	BUILD_SLAPD=yes
 	BUILD_LDBM=$ol_enable_ldbm
 	if test "$ol_enable_ldbm" = mod ; then
@@ -3024,8 +3028,9 @@ if test "$ol_enable_valsort" != no ; then
 	AC_DEFINE_UNQUOTED(SLAPD_OVER_VALSORT,$MFLAG,[define for Value Sorting overlay])
 fi
 
-if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
-	$BUILD_SLAPD = yes ; then
+if test "$ol_enable_slurpd" != no &&
+   test "$ol_link_threads" != no &&
+   test $BUILD_SLAPD = yes ; then
 	BUILD_SLURPD=yes
 fi
 
diff --git a/contrib/ldaptcl/configure b/contrib/ldaptcl/configure
index 5779bbd245..2137d294fb 100755
--- a/contrib/ldaptcl/configure
+++ b/contrib/ldaptcl/configure
@@ -1002,7 +1002,7 @@ else
   ok=no
 fi
 
-if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
+if test "$ok" = "yes" && test "${SHLIB_SUFFIX}" != ""; then
     NEO_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
     eval "NEO_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
     MAKE_LIB="\${SHLIB_LD} $TCL_LIB_HNAME -o ${NEO_LIB_FILE} \${OBJS} \${LDAP_LIBFLAGS}"
diff --git a/contrib/ldaptcl/configure.in b/contrib/ldaptcl/configure.in
index 804c39087f..71ac2a67b1 100644
--- a/contrib/ldaptcl/configure.in
+++ b/contrib/ldaptcl/configure.in
@@ -113,7 +113,7 @@ eval "NEO_UNSHARED_LIB_FILE=libldaptcl${TCL_UNSHARED_LIB_SUFFIX}"
 AC_ARG_ENABLE(shared,
     [  --enable-shared         build libldaptcl as a shared library],
     [ok=$enableval], [ok=no])
-if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
+if test "$ok" = "yes" && test "${SHLIB_SUFFIX}" != ""; then
     NEO_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
     eval "NEO_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
     MAKE_LIB="\${SHLIB_LD} $TCL_LIB_HNAME -o ${NEO_LIB_FILE} \${OBJS} \${LDAP_LIBFLAGS}"
diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in
index 1765cd0c0e..408126e010 100644
--- a/servers/slapd/Makefile.in
+++ b/servers/slapd/Makefile.in
@@ -337,7 +337,7 @@ backends.o: backends.c $(srcdir)/slap.h
 
 depend-local-srv: FORCE
 	@for i in $(SUBDIRS); do \
-		if test -d $$i -a -f $$i/Makefile ; then \
+		if test -d $$i && test -f $$i/Makefile ; then \
 			echo; echo "  cd $$i; $(MAKE) $(MFLAGS) depend"; \
 			( cd $$i; $(MAKE) $(MFLAGS) depend ); \
 			if test $$? != 0 ; then exit 1; fi ; \
@@ -353,7 +353,7 @@ veryclean-local:
 
 clean-local-srv: FORCE
 	@for i in $(SUBDIRS); do \
-		if test -d $$i -a -f $$i/Makefile ; then \
+		if test -d $$i && test -f $$i/Makefile ; then \
 			echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
 			( cd $$i; $(MAKE) $(MFLAGS) clean ); \
 			if test $$? != 0 ; then exit 1; fi ; \
@@ -363,7 +363,7 @@ clean-local-srv: FORCE
 
 veryclean-local-srv: FORCE
 	@for i in $(SUBDIRS); do \
-		if test -d $$i -a -f $$i/Makefile ; then \
+		if test -d $$i && test -f $$i/Makefile ; then \
 			echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
 			( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
 		fi; \
@@ -378,7 +378,7 @@ install-slapd: FORCE
 	$(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 \
 		slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
 	@for i in $(SUBDIRS); do \
-	    if test -d $$i -a -f $$i/Makefile ; then \
+	    if test -d $$i && test -f $$i/Makefile ; then \
 		echo; echo "  cd $$i; $(MAKE) $(MFLAGS) install"; \
 		( cd $$i; $(MAKE) $(MFLAGS) install ); \
 		if test $$? != 0 ; then exit 1; fi ; \
diff --git a/tests/scripts/acfilter.sh b/tests/scripts/acfilter.sh
index 5d7558c300..2d6023842e 100755
--- a/tests/scripts/acfilter.sh
+++ b/tests/scripts/acfilter.sh
@@ -15,4 +15,4 @@
 #
 # Strip comments
 #
-egrep -iv '^#'
+grep -v '^#'
diff --git a/tests/scripts/test000-rootdse b/tests/scripts/test000-rootdse
index d6651a6724..15c0710653 100755
--- a/tests/scripts/test000-rootdse
+++ b/tests/scripts/test000-rootdse
@@ -51,13 +51,14 @@ fi
 
 count=2
 if test $RC = 0 ; then
-	if test $MONITORDB = yes -o $MONITORDB = mod ; then
+	case $MONITORDB in yes | mod)
 		count=3
 		echo "Using ldapsearch to retrieve the cn=Monitor..."
 		$LDAPSEARCH -b "cn=Monitor" -s base -h $LOCALHOST -p $PORT1 \
 			'+extensibleObject' >> $SEARCHOUT 2>&1
 		RC=$?
-	fi
+		;;
+	esac
 fi
 
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
diff --git a/tests/scripts/test018-syncreplication-persist b/tests/scripts/test018-syncreplication-persist
index b08c7faceb..db2df02054 100755
--- a/tests/scripts/test018-syncreplication-persist
+++ b/tests/scripts/test018-syncreplication-persist
@@ -13,7 +13,7 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 
-if test "$BACKEND" != "bdb" -a "$BACKEND" != "hdb" ; then
+if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
 	echo "Test does not support $BACKEND"
 	exit 0
 fi
diff --git a/tests/scripts/test019-syncreplication-cascade b/tests/scripts/test019-syncreplication-cascade
index fce1baac19..2aa89e47dc 100755
--- a/tests/scripts/test019-syncreplication-cascade
+++ b/tests/scripts/test019-syncreplication-cascade
@@ -13,7 +13,7 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 
-if test "$BACKEND" != "bdb" -a "$BACKEND" != "hdb" ; then
+if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
 	echo "Test does not support $BACKEND"
 	exit 0
 fi
diff --git a/tests/scripts/test036-meta-concurrency b/tests/scripts/test036-meta-concurrency
index 958f7842e3..b802c1372b 100755
--- a/tests/scripts/test036-meta-concurrency
+++ b/tests/scripts/test036-meta-concurrency
@@ -40,7 +40,7 @@ rm -rf $TESTDIR
 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
 
 # NOTE: this could be added to all tests...
-if test "$BACKEND" = "bdb" -o "$BACKEND" = "hdb" ; then
+if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
 	if test "x$DB_CONFIG" != "x" ; then \
 		if test -f $DB_CONFIG ; then
 			echo "==> using DB_CONFIG \"$DB_CONFIG\""
-- 
GitLab