Skip to content

Commit 9e230d4

Browse files
committed
build/*.m4: Remove Bashisms/POSIX-ify the M4 helper macros
This commit makes it possible to build ModSecurity on systems where /bin/sh is a POSIX-compliant shell that is not Bash. Debian, Alpine Linux, and Gentoo Linux with the system shell set to not Bash, are examples of such systems. Previously, the helper macros contained two types of Bashisms: * The '==' comparison operator. Very easy to change, as the proper POSIX-compliant form is '='. For example: if test "${var}" == "myvalue" -> if test "${var}" = "myvalue" * The '-a' (and) operator in the 'test' builtin. The '-a' and '-o' operators were removed in POSIX 2024 (Issue 8). The correct form is to use the '&&' and '||' operators respectively. For instance: if test -d "${var}" -a -r "${var}/file" -> if test -d "${var}" && test -r "${var}/file" Bug: https://bugs.gentoo.org/887135 Signed-off-by: Zurab Kvachadze <[email protected]>
1 parent 7a986c7 commit 9e230d4

File tree

11 files changed

+44
-44
lines changed

11 files changed

+44
-44
lines changed

build/curl.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ AC_MSG_CHECKING([for libcurl config script])
2525
2626
for x in ${test_paths}; do
2727
dnl # Determine if the script was specified and use it directly
28-
if test ! -d "$x" -a -e "$x"; then
28+
if test ! -d "$x" && test -e "$x"; then
2929
CURL_CONFIG=$x
3030
curl_path="no"
3131
break
@@ -100,7 +100,7 @@ AC_SUBST(CURL_LDFLAGS)
100100
AC_SUBST(CURL_LDADD)
101101
AC_SUBST(CURL_USES_GNUTLS)
102102
103-
if test "x${with_curl}" == "xno"; then
103+
if test "x${with_curl}" = "xno"; then
104104
CURL_DISABLED=yes
105105
else
106106
if test "x${with_curl}" != "x"; then

build/libgeoip.m4

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ AC_ARG_WITH(
3939
# )
4040
4141
42-
if test "x${with_geoip}" == "xno"; then
42+
if test "x${with_geoip}" = "xno"; then
4343
AC_DEFINE(HAVE_GEOIP, 0, [Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no])
4444
AC_MSG_NOTICE([Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no])
4545
GEOIP_DISABLED=yes
4646
else
47-
if test "x${with_geoip}" == "xyes"; then
47+
if test "x${with_geoip}" = "xyes"; then
4848
GEOIP_MANDATORY=yes
4949
AC_MSG_NOTICE([GeoIP support was marked as mandatory by the utilization of --with-geoip=yes])
5050
fi
@@ -55,8 +55,8 @@ else
5555
# fi
5656
# done
5757
58-
# if test "x${with_geoip}" != "xyes" or test "x${with_geoip}" == "xyes"; then
59-
if test "x${with_geoip}" == "x" || test "x${with_geoip}" == "xyes"; then
58+
# if test "x${with_geoip}" != "xyes" or test "x${with_geoip}" = "xyes"; then
59+
if test "x${with_geoip}" = "x" || test "x${with_geoip}" = "xyes"; then
6060
# Nothing about GeoIP was informed, using the pkg-config to figure things out.
6161
if test -n "${PKG_CONFIG}"; then
6262
GEOIP_PKG_NAME=""
@@ -170,13 +170,13 @@ AC_DEFUN([CHECK_FOR_GEOIP_AT], [
170170
fi
171171
172172
173-
if test -n "${geoip_inc_path}" -a -n "${geoip_lib_path}"; then
173+
if test -n "${geoip_inc_path}" && test -n "${geoip_lib_path}"; then
174174
175175
AC_MSG_NOTICE([GeoIP headers found at: ${geoip_inc_path}])
176176
AC_MSG_NOTICE([GeoIP library found at: ${geoip_lib_file}])
177177
fi
178178
179-
if test -n "${geoip_lib_path}" -a -n "${geoip_inc_path}"; then
179+
if test -n "${geoip_lib_path}" && test -n "${geoip_inc_path}"; then
180180
# TODO: Compile a piece of code to check the version.
181181
GEOIP_CFLAGS="-I${geoip_inc_path}"
182182
GEOIP_LDADD="-l${geoip_lib_name}"

build/libmaxmind.m4

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ AC_ARG_WITH(
3939
# )
4040
4141
42-
if test "x${with_maxmind}" == "xno"; then
42+
if test "x${with_maxmind}" = "xno"; then
4343
AC_DEFINE(HAVE_MAXMIND, 0, [Support for MaxMind was disabled by the utilization of --without-maxmind or --with-maxmind=no])
4444
AC_MSG_NOTICE([Support for MaxMind was disabled by the utilization of --without-maxmind or --with-maxmind=no])
4545
MAXMIND_DISABLED=yes
4646
else
47-
if test "x${with_maxmind}" == "xyes"; then
47+
if test "x${with_maxmind}" = "xyes"; then
4848
MAXMIND_MANDATORY=yes
4949
AC_MSG_NOTICE([MaxMind support was marked as mandatory by the utilization of --with-maxmind=yes])
5050
fi
@@ -55,8 +55,8 @@ else
5555
# fi
5656
# done
5757
58-
# if test "x${with_maxmind}" != "xyes" or test "x${with_maxmind}" == "xyes"; then
59-
if test "x${with_maxmind}" == "x" || test "x${with_maxmind}" == "xyes"; then
58+
# if test "x${with_maxmind}" != "xyes" or test "x${with_maxmind}" = "xyes"; then
59+
if test "x${with_maxmind}" = "x" || test "x${with_maxmind}" = "xyes"; then
6060
# Nothing about MaxMind was informed, using the pkg-config to figure things out.
6161
if test -n "${PKG_CONFIG}"; then
6262
MAXMIND_PKG_NAME=""
@@ -171,13 +171,13 @@ AC_DEFUN([CHECK_FOR_MAXMIND_AT], [
171171
fi
172172
173173
174-
if test -n "${maxmind_inc_path}" -a -n "${maxmind_lib_path}"; then
174+
if test -n "${maxmind_inc_path}" && test -n "${maxmind_lib_path}"; then
175175
176176
AC_MSG_NOTICE([MaxMind headers found at: ${maxmind_inc_path}])
177177
AC_MSG_NOTICE([MaxMind library found at: ${maxmind_lib_file}])
178178
fi
179179
180-
if test -n "${maxmind_lib_path}" -a -n "${maxmind_inc_path}"; then
180+
if test -n "${maxmind_lib_path}" && test -n "${maxmind_inc_path}"; then
181181
# TODO: Compile a piece of code to check the version.
182182
MAXMIND_CFLAGS="-I${maxmind_inc_path}"
183183
MAXMIND_LDADD="-l${maxmind_lib_name}"

build/libxml.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AC_MSG_CHECKING([for libxml2 config script])
1010
1111
for x in ${test_paths}; do
1212
dnl # Determine if the script was specified and use it directly
13-
if test ! -d "$x" -a -e "$x"; then
13+
if test ! -d "$x" && test -e "$x"; then
1414
LIBXML2_CONFIG=$x
1515
libxml2_path="no"
1616
break
@@ -104,7 +104,7 @@ AC_SUBST(LIBXML2_LDADD)
104104
AC_SUBST(LIBXML2_LDFLAGS)
105105
106106
107-
if test "x${with_libxml}" == "xno"; then
107+
if test "x${with_libxml}" = "xno"; then
108108
LIBXML2_DISABLED=yes
109109
else
110110
if test "x${with_libxml}" != "x"; then

build/lmdb.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ AC_ARG_WITH(
2424
[AS_HELP_STRING([--with-lmdb=PATH],[Path to lmdb prefix or config script])]
2525
)
2626
27-
if test "x${with_lmdb}" == "xno"; then
27+
if test "x${with_lmdb}" = "xno"; then
2828
AC_DEFINE(HAVE_LMDB, 0, [Support for LMDB was disabled by the utilization of --without-lmdb or --with-lmdb=no])
2929
AC_MSG_NOTICE([Support for LMDB was disabled by the utilization of --without-lmdb or --with-lmdb=no])
3030
LMDB_DISABLED=yes
3131
else
32-
if test "x${with_lmdb}" == "xyes"; then
32+
if test "x${with_lmdb}" = "xyes"; then
3333
LMDB_MANDATORY=yes
3434
AC_MSG_NOTICE([LMDB support was marked as mandatory by the utilization of --with-lmdb=yes])
3535
fi
@@ -40,8 +40,8 @@ else
4040
# fi
4141
# done
4242
43-
# if test "x${with_lmdb}" != "xyes" or test "x${with_lmdb}" == "xyes"; then
44-
if test "x${with_lmdb}" == "x" || test "x${with_lmdb}" == "xyes"; then
43+
# if test "x${with_lmdb}" != "xyes" or test "x${with_lmdb}" = "xyes"; then
44+
if test "x${with_lmdb}" = "x" || test "x${with_lmdb}" = "xyes"; then
4545
# Nothing about LMDB was informed, using the pkg-config to figure things out.
4646
if test -n "${PKG_CONFIG}"; then
4747
LMDB_PKG_NAME=""
@@ -170,7 +170,7 @@ AC_DEFUN([CHECK_FOR_LMDB_AT], [
170170
AC_MSG_NOTICE([LMDB headers found at: ${lmdb_inc_path}])
171171
fi
172172
173-
if test -n "${lmdb_lib_path}" -a -n "${lmdb_inc_path}"; then
173+
if test -n "${lmdb_lib_path}" && test -n "${lmdb_inc_path}"; then
174174
# TODO: Compile a piece of code to check the version.
175175
LMDB_CFLAGS="-I${lmdb_inc_path}"
176176
LMDB_LDADD="-l${lmdb_lib_name}"

build/lua.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ AC_ARG_WITH(
2626
)
2727
2828
29-
if test "x${with_lua}" == "xno"; then
29+
if test "x${with_lua}" = "xno"; then
3030
AC_DEFINE(HAVE_LUA, 0, [Support for LUA was disabled by the utilization of --without-lua or --with-lua=no])
3131
AC_MSG_NOTICE([Support for LUA was disabled by the utilization of --without-lua or --with-lua=no])
3232
LUA_DISABLED=yes
3333
else
34-
if test "x${with_lua}" == "xyes"; then
34+
if test "x${with_lua}" = "xyes"; then
3535
LUA_MANDATORY=yes
3636
AC_MSG_NOTICE([LUA support was marked as mandatory by the utilization of --with-lua=yes])
3737
else
@@ -77,7 +77,7 @@ fi
7777
7878
7979
if test -z "${LUA_CFLAGS}"; then
80-
if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" == "xno"; then
80+
if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" = "xno"; then
8181
if test -z "${LUA_DISABLED}"; then
8282
AC_MSG_NOTICE([LUA library was not found])
8383
LUA_FOUND=0
@@ -89,7 +89,7 @@ if test -z "${LUA_CFLAGS}"; then
8989
LUA_FOUND=-1
9090
fi
9191
else
92-
if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" == "xno"; then
92+
if test -z "${LUA_MANDATORY}" || test "x${LUA_MANDATORY}" = "xno"; then
9393
LUA_FOUND=1
9494
AC_MSG_NOTICE([using LUA ${LUA_LDADD}])
9595
LUA_CFLAGS="-DWITH_LUA ${LUA_CFLAGS}"
@@ -185,7 +185,7 @@ AC_DEFUN([CHECK_FOR_LUA_AT], [
185185
if test -n "${lua_inc_path}"; then
186186
AC_MSG_NOTICE([LUA headers found at: ${lua_inc_path}])
187187
fi
188-
if test -n "${lua_lib_path}" -a -n "${lua_inc_path}"; then
188+
if test -n "${lua_lib_path}" && test -n "${lua_inc_path}"; then
189189
LUA_CFLAGS="-I${lua_inc_path}"
190190
LUA_LDADD="-l${lua_lib_name}"
191191
LUA_LDFLAGS="-L${lua_lib_path}"

build/pcre.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AC_ARG_WITH(
2121
[test_paths="${with_pcre}"],
2222
[test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr /opt/local"])
2323
24-
if test "x${with_pcre}" == "x" && test "x${with_pcre}" != "xno"; then
24+
if test "x${with_pcre}" = "x" && test "x${with_pcre}" != "xno"; then
2525
AC_MSG_NOTICE([Support for pcre not requested; omitting check for pcre])
2626
else
2727
@@ -39,7 +39,7 @@ else
3939
4040
for x in ${test_paths}; do
4141
dnl # Determine if the script was specified and use it directly
42-
if test ! -d "$x" -a -e "$x"; then
42+
if test ! -d "$x" && test -e "$x"; then
4343
PCRE_CONFIG=$x
4444
pcre_path="no"
4545
break

build/pcre2.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ AC_ARG_WITH(
2424
[AS_HELP_STRING([--with-pcre2=PATH],[Path to pcre2 prefix or config script])]
2525
)
2626
27-
if test "x${with_pcre2}" == "xno"; then
27+
if test "x${with_pcre2}" = "xno"; then
2828
AC_DEFINE(HAVE_PCRE2, 0, [Support for PCRE2 was disabled by the utilization of --without-pcre2 or --with-pcre2=no])
2929
AC_MSG_NOTICE([Support for PCRE2 was disabled by the utilization of --without-pcre2 or --with-pcre2=no])
3030
PCRE2_DISABLED=yes
3131
else
3232
PCRE2_MANDATORY=yes
3333
AC_MSG_NOTICE([PCRE2 is enabled by default.])
34-
# if test "x${with_pcre2}" == "xyes"; then
34+
# if test "x${with_pcre2}" = "xyes"; then
3535
# PCRE2_MANDATORY=yes
3636
# AC_MSG_NOTICE([PCRE2 support was marked as mandatory by the utilization of --with-pcre2=yes])
3737
# fi
@@ -42,8 +42,8 @@ else
4242
# fi
4343
# done
4444
45-
# if test "x${with_pcre2}" != "xyes" or test "x${with_pcre2}" == "xyes"; then
46-
if test "x${with_pcre2}" == "x" || test "x${with_pcre2}" == "xyes"; then
45+
# if test "x${with_pcre2}" != "xyes" or test "x${with_pcre2}" = "xyes"; then
46+
if test "x${with_pcre2}" = "x" || test "x${with_pcre2}" = "xyes"; then
4747
# Nothing about PCRE2 was informed, using the pkg-config to figure things out.
4848
if test -n "${PKG_CONFIG}"; then
4949
PCRE2_PKG_NAME=""
@@ -177,7 +177,7 @@ AC_DEFUN([CHECK_FOR_PCRE2_AT], [
177177
AC_MSG_NOTICE([PCRE2 headers found at: ${pcre2_inc_path}])
178178
fi
179179
180-
if test -n "${pcre2_lib_path}" -a -n "${pcre2_inc_path}"; then
180+
if test -n "${pcre2_lib_path}" && test -n "${pcre2_inc_path}"; then
181181
# TODO: Compile a piece of code to check the version.
182182
PCRE2_CFLAGS="-I${pcre2_inc_path}"
183183
PCRE2_LDADD="-l${pcre2_lib_name}"

build/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
git clean -xfdi
44
git submodule foreach --recursive git clean -xfdi
55

6-
VERSION=`git describe --tags`
6+
VERSION=$(git describe --tags)
77
DIR_NAME="modsecurity-$VERSION"
88
TAR_NAME="modsecurity-$VERSION.tar.gz"
99

build/ssdeep.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ AC_ARG_WITH(
2626
)
2727
2828
29-
if test "x${with_ssdeep}" == "xno"; then
29+
if test "x${with_ssdeep}" = "xno"; then
3030
AC_DEFINE(HAVE_SSDEEP, 0, [Support for SSDEEP was disabled by the utilization of --without-ssdeep or --with-ssdeep=no])
3131
AC_MSG_NOTICE([Support for SSDEEP was disabled by the utilization of --without-ssdeep or --with-ssdeep=no])
3232
SSDEEP_DISABLED=yes
3333
else
34-
if test "x${with_ssdeep}" == "xyes"; then
34+
if test "x${with_ssdeep}" = "xyes"; then
3535
SSDEEP_MANDATORY=yes
3636
AC_MSG_NOTICE([SSDEEP support was marked as mandatory by the utilization of --with-ssdeep=yes])
3737
else
@@ -47,7 +47,7 @@ fi
4747
4848
4949
if test -z "${SSDEEP_CFLAGS}"; then
50-
if test -z "${SSDEEP_MANDATORY}" || test "x${SSDEEP_MANDATORY}" == "xno"; then
50+
if test -z "${SSDEEP_MANDATORY}" || test "x${SSDEEP_MANDATORY}" = "xno"; then
5151
if test -z "${SSDEEP_DISABLED}"; then
5252
AC_MSG_NOTICE([SSDEEP library was not found])
5353
SSDEEP_FOUND=0
@@ -131,7 +131,7 @@ AC_DEFUN([CHECK_FOR_SSDEEP_AT], [
131131
AC_MSG_NOTICE([SSDEEP headers found at: ${ssdeep_inc_path}])
132132
fi
133133
134-
if test -n "${ssdeep_lib_path}" -a -n "${ssdeep_inc_path}"; then
134+
if test -n "${ssdeep_lib_path}" && test -n "${ssdeep_inc_path}"; then
135135
# TODO: Compile a piece of code to check the version.
136136
SSDEEP_CFLAGS="-I${ssdeep_inc_path}"
137137
SSDEEP_LDADD="-l${ssdeep_lib_name}"

0 commit comments

Comments
 (0)