Skip to content

build/*.m4: Remove Bashisms/POSIX-ify the M4 helper macros #3359

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: v3/master
Choose a base branch
from

Conversation

BalkanMadman
Copy link

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 -a operator changed to the compliant &&.

why

  • Unable to build ModSecurity on systems where /bin/sh is not Bash (is dash, ash, etc.). See the Gentoo bug below.

references

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 <zurabid2016@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant