build: remove x-prefix comparisons

Very old shells suffered from bugs which meant that prefixing variables
with an "x" to ensure that the lefthand side of a comparison always
started with an alphanumeric character was needed. Modern shells don't
suffer from this issue (i.e Bash was fixed in 1996).

In any case, we've already got unprefixed checks used in our codebase,
i.e https://github.com/bitcoin/bitcoin/blob/master/configure.ac#L292,
and have dependencies (in depends) that also use unprefixed comparisons.

I think it's time that we can consolidate on not using the x-prefix
workaround. At best it's mostly just confusing.

More info:
https://github.com/koalaman/shellcheck/wiki/SC2268
https://www.vidarholen.net/contents/blog/?p=1035
This commit is contained in:
fanquake
2021-11-24 20:16:53 +08:00
parent c9b63ab61e
commit d6d402bd2b
5 changed files with 204 additions and 204 deletions

View File

@@ -6,9 +6,9 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
AC_ARG_VAR([BDB_CFLAGS], [C compiler flags for BerkeleyDB, bypasses autodetection])
AC_ARG_VAR([BDB_LIBS], [Linker flags for BerkeleyDB, bypasses autodetection])
if test "x$use_bdb" = "xno"; then
if test "$use_bdb" = "no"; then
use_bdb=no
elif test "x$BDB_CFLAGS" = "x"; then
elif test "$BDB_CFLAGS" = ""; then
AC_MSG_CHECKING([for Berkeley DB C++ headers])
BDB_CPPFLAGS=
bdbpath=X
@@ -28,7 +28,7 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
#error "failed to find bdb 4.8+"
#endif
]])],[
if test "x$bdbpath" = "xX"; then
if test "$bdbpath" = "X"; then
bdbpath="${searchpath}"
fi
],[
@@ -45,13 +45,13 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
break
],[])
done
if test "x$bdbpath" = "xX"; then
if test "$bdbpath" = "X"; then
use_bdb=no
AC_MSG_RESULT([no])
AC_MSG_WARN([libdb_cxx headers missing])
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
elif test "x$bdb48path" = "xX"; then
elif test "$bdb48path" = "X"; then
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
AC_MSG_WARN([Found Berkeley DB other than 4.8])
@@ -74,9 +74,9 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
fi
AC_SUBST(BDB_CPPFLAGS)
if test "x$use_bdb" = "xno"; then
if test "$use_bdb" = "no"; then
use_bdb=no
elif test "x$BDB_LIBS" = "x"; then
elif test "$BDB_LIBS" = ""; then
# TODO: Ideally this could find the library version and make sure it matches the headers being used
for searchlib in db_cxx-4.8 db_cxx db4_cxx; do
AC_CHECK_LIB([$searchlib],[main],[
@@ -84,13 +84,13 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
break
])
done
if test "x$BDB_LIBS" = "x"; then
if test "$BDB_LIBS" = ""; then
AC_MSG_WARN([libdb_cxx headers missing])
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
fi
fi
if test "x$use_bdb" != "xno"; then
if test "$use_bdb" != "no"; then
AC_SUBST(BDB_LIBS)
AC_DEFINE([USE_BDB], [1], [Define if BDB support should be compiled in])
use_bdb=yes