Skip to content

Commit 61b82a8

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23593: build: remove x-prefix's from comparisons
d6d402b build: remove x-prefix comparisons (fanquake) Pull request description: 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/681b25e3cd7d084f642693152322ed9a40f33ba0/configure.ac#L292 and have libs (in depends) that also use unprefixed comparisons in their configure scripts. I think it's time that we consolidate on not using the x-prefix workaround. At best it's mostly just confusing. Could simplify some of these checks further in future. More info: https://github.com/koalaman/shellcheck/wiki/SC2268 https://www.vidarholen.net/contents/blog/?p=1035 ACKs for top commit: MarcoFalke: Concept ACK d6d402b Tree-SHA512: 70030d61dcdb5b009823d83d73204627de53d2f628d8d6478e8e16804ac09f6bbdc53cbb1a6fb2085ebfe1a694b576e46ff381fb980cf667fab4bbadc79587d7
2 parents 89ea2b3 + d6d402b commit 61b82a8

File tree

5 files changed

+204
-204
lines changed

5 files changed

+204
-204
lines changed

build-aux/m4/bitcoin_find_bdb48.m4

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
66
AC_ARG_VAR([BDB_CFLAGS], [C compiler flags for BerkeleyDB, bypasses autodetection])
77
AC_ARG_VAR([BDB_LIBS], [Linker flags for BerkeleyDB, bypasses autodetection])
88
9-
if test "x$use_bdb" = "xno"; then
9+
if test "$use_bdb" = "no"; then
1010
use_bdb=no
11-
elif test "x$BDB_CFLAGS" = "x"; then
11+
elif test "$BDB_CFLAGS" = ""; then
1212
AC_MSG_CHECKING([for Berkeley DB C++ headers])
1313
BDB_CPPFLAGS=
1414
bdbpath=X
@@ -28,7 +28,7 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
2828
#error "failed to find bdb 4.8+"
2929
#endif
3030
]])],[
31-
if test "x$bdbpath" = "xX"; then
31+
if test "$bdbpath" = "X"; then
3232
bdbpath="${searchpath}"
3333
fi
3434
],[
@@ -45,13 +45,13 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
4545
break
4646
],[])
4747
done
48-
if test "x$bdbpath" = "xX"; then
48+
if test "$bdbpath" = "X"; then
4949
use_bdb=no
5050
AC_MSG_RESULT([no])
5151
AC_MSG_WARN([libdb_cxx headers missing])
5252
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
5353
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
54-
elif test "x$bdb48path" = "xX"; then
54+
elif test "$bdb48path" = "X"; then
5555
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
5656
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
5757
AC_MSG_WARN([Found Berkeley DB other than 4.8])
@@ -74,23 +74,23 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
7474
fi
7575
AC_SUBST(BDB_CPPFLAGS)
7676
77-
if test "x$use_bdb" = "xno"; then
77+
if test "$use_bdb" = "no"; then
7878
use_bdb=no
79-
elif test "x$BDB_LIBS" = "x"; then
79+
elif test "$BDB_LIBS" = ""; then
8080
# TODO: Ideally this could find the library version and make sure it matches the headers being used
8181
for searchlib in db_cxx-4.8 db_cxx db4_cxx; do
8282
AC_CHECK_LIB([$searchlib],[main],[
8383
BDB_LIBS="-l${searchlib}"
8484
break
8585
])
8686
done
87-
if test "x$BDB_LIBS" = "x"; then
87+
if test "$BDB_LIBS" = ""; then
8888
AC_MSG_WARN([libdb_cxx headers missing])
8989
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
9090
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
9191
fi
9292
fi
93-
if test "x$use_bdb" != "xno"; then
93+
if test "$use_bdb" != "no"; then
9494
AC_SUBST(BDB_LIBS)
9595
AC_DEFINE([USE_BDB], [1], [Define if BDB support should be compiled in])
9696
use_bdb=yes

build-aux/m4/bitcoin_qt.m4

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
dnl Helper for cases where a qt dependency is not met.
66
dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit.
77
AC_DEFUN([BITCOIN_QT_FAIL],[
8-
if test "x$bitcoin_qt_want_version" = xauto && test "x$bitcoin_qt_force" != xyes; then
9-
if test "x$bitcoin_enable_qt" != xno; then
8+
if test "$bitcoin_qt_want_version" = "auto" && test "$bitcoin_qt_force" != "yes"; then
9+
if test "$bitcoin_enable_qt" != "no"; then
1010
AC_MSG_WARN([$1; bitcoin-qt frontend will not be built])
1111
fi
1212
bitcoin_enable_qt=no
@@ -17,7 +17,7 @@ AC_DEFUN([BITCOIN_QT_FAIL],[
1717
])
1818

1919
AC_DEFUN([BITCOIN_QT_CHECK],[
20-
if test "x$bitcoin_enable_qt" != xno && test "x$bitcoin_qt_want_version" != xno; then
20+
if test "$bitcoin_enable_qt" != "no" && test "$bitcoin_qt_want_version" != "no"; then
2121
true
2222
$1
2323
else
@@ -35,12 +35,12 @@ dnl Inputs: $4: If "yes", don't fail if $2 is not found.
3535
dnl Output: $1 is set to the path of $2 if found. $2 are searched in order.
3636
AC_DEFUN([BITCOIN_QT_PATH_PROGS],[
3737
BITCOIN_QT_CHECK([
38-
if test "x$3" != x; then
38+
if test "$3" != ""; then
3939
AC_PATH_PROGS([$1], [$2], [], [$3])
4040
else
4141
AC_PATH_PROGS([$1], [$2])
4242
fi
43-
if test "x$$1" = x && test "x$4" != xyes; then
43+
if test "$$1" = "" && test "$4" != "yes"; then
4444
BITCOIN_QT_FAIL([$1 not found])
4545
fi
4646
])
@@ -57,14 +57,14 @@ AC_DEFUN([BITCOIN_QT_INIT],[
5757
[build bitcoin-qt GUI (default=auto)])],
5858
[
5959
bitcoin_qt_want_version=$withval
60-
if test "x$bitcoin_qt_want_version" = xyes; then
60+
if test "$bitcoin_qt_want_version" = "yes"; then
6161
bitcoin_qt_force=yes
6262
bitcoin_qt_want_version=auto
6363
fi
6464
],
6565
[bitcoin_qt_want_version=auto])
6666
67-
AS_IF([test "x$with_gui" = xqt5_debug],
67+
AS_IF([test "$with_gui" = "qt5_debug"],
6868
[AS_CASE([$host],
6969
[*darwin*], [qt_lib_suffix=_debug],
7070
[qt_lib_suffix= ]); bitcoin_qt_want_version=qt5],
@@ -87,7 +87,7 @@ AC_DEFUN([BITCOIN_QT_INIT],[
8787
dnl Android doesn't support D-Bus and certainly doesn't use it for notifications
8888
case $host in
8989
*android*)
90-
if test "x$use_dbus" != xyes; then
90+
if test "$use_dbus" != "yes"; then
9191
use_dbus=no
9292
fi
9393
;;
@@ -119,10 +119,10 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
119119
CPPFLAGS="$QT_INCLUDES $CPPFLAGS"
120120
CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
121121
_BITCOIN_QT_IS_STATIC
122-
if test "x$bitcoin_cv_static_qt" = xyes; then
122+
if test "$bitcoin_cv_static_qt" = "yes"; then
123123
_BITCOIN_QT_CHECK_STATIC_LIBS
124124
125-
if test "x$qt_plugin_path" != x; then
125+
if test "$qt_plugin_path" != ""; then
126126
if test -d "$qt_plugin_path/platforms"; then
127127
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
128128
fi
@@ -138,29 +138,29 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
138138
fi
139139
140140
AC_DEFINE([QT_STATICPLUGIN], [1], [Define this symbol if qt plugins are static])
141-
if test "x$TARGET_OS" != xandroid; then
141+
if test "$TARGET_OS" != "android"; then
142142
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QMinimalIntegrationPlugin], [-lqminimal])
143143
AC_DEFINE([QT_QPA_PLATFORM_MINIMAL], [1], [Define this symbol if the minimal qt platform exists])
144144
fi
145-
if test "x$TARGET_OS" = xwindows; then
145+
if test "$TARGET_OS" = "windows"; then
146146
dnl Linking against wtsapi32 is required. See #17749 and
147147
dnl https://bugreports.qt.io/browse/QTBUG-27097.
148148
AX_CHECK_LINK_FLAG([-lwtsapi32], [QT_LIBS="$QT_LIBS -lwtsapi32"], [AC_MSG_ERROR([could not link against -lwtsapi32])])
149149
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QWindowsIntegrationPlugin], [-lqwindows])
150150
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QWindowsVistaStylePlugin], [-lqwindowsvistastyle])
151151
AC_DEFINE([QT_QPA_PLATFORM_WINDOWS], [1], [Define this symbol if the qt platform is windows])
152-
elif test "x$TARGET_OS" = xlinux; then
152+
elif test "$TARGET_OS" = "linux"; then
153153
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QXcbIntegrationPlugin], [-lqxcb])
154154
AC_DEFINE([QT_QPA_PLATFORM_XCB], [1], [Define this symbol if the qt platform is xcb])
155-
elif test "x$TARGET_OS" = xdarwin; then
155+
elif test "$TARGET_OS" = "darwin"; then
156156
AX_CHECK_LINK_FLAG([-framework Carbon], [QT_LIBS="$QT_LIBS -framework Carbon"], [AC_MSG_ERROR(could not link against Carbon framework)])
157157
AX_CHECK_LINK_FLAG([-framework IOSurface], [QT_LIBS="$QT_LIBS -framework IOSurface"], [AC_MSG_ERROR(could not link against IOSurface framework)])
158158
AX_CHECK_LINK_FLAG([-framework Metal], [QT_LIBS="$QT_LIBS -framework Metal"], [AC_MSG_ERROR(could not link against Metal framework)])
159159
AX_CHECK_LINK_FLAG([-framework QuartzCore], [QT_LIBS="$QT_LIBS -framework QuartzCore"], [AC_MSG_ERROR(could not link against QuartzCore framework)])
160160
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QCocoaIntegrationPlugin], [-lqcocoa])
161161
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QMacStylePlugin], [-lqmacstyle])
162162
AC_DEFINE([QT_QPA_PLATFORM_COCOA], [1], [Define this symbol if the qt platform is cocoa])
163-
elif test "x$TARGET_OS" = xandroid; then
163+
elif test "$TARGET_OS" = "android"; then
164164
QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lplugins_platforms_qtforandroid_$ANDROID_ARCH -ljnigraphics -landroid -lqtfreetype_$ANDROID_ARCH $QT_LIBS"
165165
AC_DEFINE([QT_QPA_PLATFORM_ANDROID], [1], [Define this symbol if the qt platform is android])
166166
fi
@@ -169,11 +169,11 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
169169
CXXFLAGS=$TEMP_CXXFLAGS
170170
])
171171
172-
if test "x$qt_bin_path" = x; then
172+
if test "$qt_bin_path" = ""; then
173173
qt_bin_path="`$PKG_CONFIG --variable=host_bins ${qt_lib_prefix}Core 2>/dev/null`"
174174
fi
175175
176-
if test "x$use_hardening" != xno; then
176+
if test "$use_hardening" != "no"; then
177177
BITCOIN_QT_CHECK([
178178
AC_MSG_CHECKING([whether -fPIE can be used with this Qt config])
179179
TEMP_CPPFLAGS=$CPPFLAGS
@@ -248,26 +248,26 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
248248
BITCOIN_QT_CHECK([
249249
bitcoin_enable_qt=yes
250250
bitcoin_enable_qt_test=yes
251-
if test "x$have_qt_test" = xno; then
251+
if test "$have_qt_test" = "no"; then
252252
bitcoin_enable_qt_test=no
253253
fi
254254
bitcoin_enable_qt_dbus=no
255-
if test "x$use_dbus" != xno && test "x$have_qt_dbus" = xyes; then
255+
if test "$use_dbus" != "no" && test "$have_qt_dbus" = "yes"; then
256256
bitcoin_enable_qt_dbus=yes
257257
fi
258-
if test "x$use_dbus" = xyes && test "x$have_qt_dbus" = xno; then
258+
if test "$use_dbus" = "yes" && test "$have_qt_dbus" = "no"; then
259259
AC_MSG_ERROR([libQtDBus not found. Install libQtDBus or remove --with-qtdbus.])
260260
fi
261-
if test "x$LUPDATE" = x; then
261+
if test "$LUPDATE" = ""; then
262262
AC_MSG_WARN([lupdate tool is required to update Qt translations.])
263263
fi
264-
if test "x$LCONVERT" = x; then
264+
if test "$LCONVERT" = ""; then
265265
AC_MSG_WARN([lconvert tool is required to update Qt translations.])
266266
fi
267267
],[
268268
bitcoin_enable_qt=no
269269
])
270-
if test x$bitcoin_enable_qt = xyes; then
270+
if test $bitcoin_enable_qt = "yes"; then
271271
AC_MSG_RESULT([$bitcoin_enable_qt ($qt_lib_prefix)])
272272
else
273273
AC_MSG_RESULT([$bitcoin_enable_qt])
@@ -348,18 +348,18 @@ AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_LIBS], [
348348
PKG_CHECK_MODULES([QT_FB], [${qt_lib_prefix}FbSupport${qt_lib_suffix}], [QT_LIBS="$QT_FB_LIBS $QT_LIBS"])
349349
PKG_CHECK_MODULES([QT_FONTDATABASE], [${qt_lib_prefix}FontDatabaseSupport${qt_lib_suffix}], [QT_LIBS="$QT_FONTDATABASE_LIBS $QT_LIBS"])
350350
PKG_CHECK_MODULES([QT_THEME], [${qt_lib_prefix}ThemeSupport${qt_lib_suffix}], [QT_LIBS="$QT_THEME_LIBS $QT_LIBS"])
351-
if test "x$TARGET_OS" = xlinux; then
351+
if test "$TARGET_OS" = "linux"; then
352352
PKG_CHECK_MODULES([QT_INPUT], [${qt_lib_prefix}InputSupport], [QT_LIBS="$QT_INPUT_LIBS $QT_LIBS"])
353353
PKG_CHECK_MODULES([QT_SERVICE], [${qt_lib_prefix}ServiceSupport], [QT_LIBS="$QT_SERVICE_LIBS $QT_LIBS"])
354354
PKG_CHECK_MODULES([QT_XCBQPA], [${qt_lib_prefix}XcbQpa], [QT_LIBS="$QT_XCBQPA_LIBS $QT_LIBS"])
355355
PKG_CHECK_MODULES([QT_XKBCOMMON], [${qt_lib_prefix}XkbCommonSupport], [QT_LIBS="$QT_XKBCOMMON_LIBS $QT_LIBS"])
356-
elif test "x$TARGET_OS" = xdarwin; then
356+
elif test "$TARGET_OS" = "darwin"; then
357357
PKG_CHECK_MODULES([QT_CLIPBOARD], [${qt_lib_prefix}ClipboardSupport${qt_lib_suffix}], [QT_LIBS="$QT_CLIPBOARD_LIBS $QT_LIBS"])
358358
PKG_CHECK_MODULES([QT_GRAPHICS], [${qt_lib_prefix}GraphicsSupport${qt_lib_suffix}], [QT_LIBS="$QT_GRAPHICS_LIBS $QT_LIBS"])
359359
PKG_CHECK_MODULES([QT_SERVICE], [${qt_lib_prefix}ServiceSupport${qt_lib_suffix}], [QT_LIBS="$QT_SERVICE_LIBS $QT_LIBS"])
360-
elif test "x$TARGET_OS" = xwindows; then
360+
elif test "$TARGET_OS" = "windows"; then
361361
PKG_CHECK_MODULES([QT_WINDOWSUIAUTOMATION], [${qt_lib_prefix}WindowsUIAutomationSupport${qt_lib_suffix}], [QT_LIBS="$QT_WINDOWSUIAUTOMATION_LIBS $QT_LIBS"])
362-
elif test "x$TARGET_OS" = xandroid; then
362+
elif test "$TARGET_OS" = "android"; then
363363
PKG_CHECK_MODULES([QT_EGL], [${qt_lib_prefix}EglSupport${qt_lib_suffix}], [QT_LIBS="$QT_EGL_LIBS $QT_LIBS"])
364364
PKG_CHECK_MODULES([QT_SERVICE], [${qt_lib_prefix}ServiceSupport${qt_lib_suffix}], [QT_LIBS="$QT_SERVICE_LIBS $QT_LIBS"])
365365
fi
@@ -392,7 +392,7 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[
392392
393393
BITCOIN_QT_CHECK([
394394
PKG_CHECK_MODULES([QT_TEST], [${qt_lib_prefix}Test${qt_lib_suffix} $qt_version], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no])
395-
if test "x$use_dbus" != xno; then
395+
if test "$use_dbus" != "no"; then
396396
PKG_CHECK_MODULES([QT_DBUS], [${qt_lib_prefix}DBus $qt_version], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
397397
fi
398398
])

build-aux/m4/bitcoin_subdir_to_include.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
dnl BITCOIN_SUBDIR_TO_INCLUDE([CPPFLAGS-VARIABLE-NAME],[SUBDIRECTORY-NAME],[HEADER-FILE])
66
dnl SUBDIRECTORY-NAME must end with a path separator
77
AC_DEFUN([BITCOIN_SUBDIR_TO_INCLUDE],[
8-
if test "x$2" = "x"; then
8+
if test "$2" = ""; then
99
AC_MSG_RESULT([default])
1010
else
1111
echo "#include <$2$3.h>" >conftest.cpp
1212
newinclpath=`${CXXCPP} ${CPPFLAGS} -M conftest.cpp 2>/dev/null | [ tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)]$3[\.h[[:space:]].*$/\1/' -e t -e d`]
1313
AC_MSG_RESULT([${newinclpath}])
14-
if test "x${newinclpath}" != "x"; then
14+
if test "${newinclpath}" != ""; then
1515
eval "$1=\"\$$1\"' -I${newinclpath}'"
1616
fi
1717
fi

0 commit comments

Comments
 (0)