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
what
- The Bash
==operator changed to the POSIX-compliant=. - The obsolete and removed in POSIX 2024
-aoperator changed to the compliant&&.
why
- Unable to build ModSecurity on systems where
/bin/shis not Bash (is dash, ash, etc.). See the Gentoo bug below.
references
- The Gentoo bug: https://bugs.gentoo.org/887135
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Hi @BalkanMadman,
first of all, many thanks for this PR. I think this is a really important patch, we must apply this.
Please take a look at my comment above - I don't expect you to review all conditions, but that would be a huge help for the project.
Also, could you take a look at the v2/master tree too, and make this modifications?