From 570814a31e4fa7664596e99f660701aad795a0dc Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Tue, 16 Jul 2024 20:41:50 +0900 Subject: [PATCH] Meta: Make all pre-commit CI scripts work with Bash 3.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change makes all the pre-commit CI scripts runnable under Bash 3.2, by replacing “mapfile” invocations in them code that first explicitly creates an array, and then uses a while loop to populate the array. Otherwise, without this change, the scripts all fail to run under Bash 3.2 — due to lack of support for “mapfile”. Fixes https://github.com/LadybirdBrowser/ladybird/issues/283 This also drops bash from the list of homebrew dependencies in the build instructions — because with this change, homebrew bash (v4) is no longer needed; things will now work with the Apple-provided bash (v3.2) --- Documentation/BuildInstructionsLadybird.md | 2 +- Meta/lint-clang-format.sh | 5 ++++- Meta/lint-gn.sh | 5 ++++- Meta/lint-prettier.sh | 5 ++++- Meta/lint-python.sh | 5 ++++- Meta/lint-shell-scripts.sh | 5 ++++- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index 9c75d1d6596..67258fc916f 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -107,7 +107,7 @@ Xcode 14 versions before 14.3 might crash while building ladybird. Xcode 14.3 or ``` xcode-select --install -brew install autoconf autoconf-archive automake cmake ffmpeg nasm ninja ccache pkg-config bash +brew install autoconf autoconf-archive automake cmake ffmpeg nasm ninja ccache pkg-config ``` If you also plan to use the Qt chrome on macOS: diff --git a/Meta/lint-clang-format.sh b/Meta/lint-clang-format.sh index 384a09bf338..68304ec7aa8 100755 --- a/Meta/lint-clang-format.sh +++ b/Meta/lint-clang-format.sh @@ -6,7 +6,10 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "${script_path}/.." || exit 1 if [ "$#" -eq "1" ]; then - mapfile -t files < <( + files=() + while IFS= read -r file; do + files+=("$file") + done < <( git ls-files -- \ '*.cpp' \ '*.h' \ diff --git a/Meta/lint-gn.sh b/Meta/lint-gn.sh index bf43fbb5704..e8970bcd40a 100755 --- a/Meta/lint-gn.sh +++ b/Meta/lint-gn.sh @@ -6,7 +6,10 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "${script_path}/.." || exit 1 if [ "$#" -eq "0" ]; then - mapfile -t files < <( + files=() + while IFS= read -r file; do + files+=("$file") + done < <( git ls-files '*.gn' '*.gni' ) else diff --git a/Meta/lint-prettier.sh b/Meta/lint-prettier.sh index 00f0f70b4ee..00915412d40 100755 --- a/Meta/lint-prettier.sh +++ b/Meta/lint-prettier.sh @@ -6,7 +6,10 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "${script_path}/.." || exit 1 if [ "$#" -eq "0" ]; then - mapfile -t files < <( + files=() + while IFS= read -r file; do + files+=("$file") + done < <( git ls-files \ --exclude-from .prettierignore \ -- \ diff --git a/Meta/lint-python.sh b/Meta/lint-python.sh index 40eb8126539..b4995e1d770 100755 --- a/Meta/lint-python.sh +++ b/Meta/lint-python.sh @@ -6,7 +6,10 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "${script_path}/.." || exit 1 if [ "$#" -eq "0" ]; then - mapfile -t files < <( + files=() + while IFS= read -r file; do + files+=("$file") + done < <( git ls-files '*.py' ) else diff --git a/Meta/lint-shell-scripts.sh b/Meta/lint-shell-scripts.sh index ac0de251ddc..8587f0d89d0 100755 --- a/Meta/lint-shell-scripts.sh +++ b/Meta/lint-shell-scripts.sh @@ -6,7 +6,10 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) cd "$script_path/.." if [ "$#" -eq "0" ]; then - mapfile -t files < <( + files=() + while IFS= read -r file; do + files+=("$file") + done < <( git ls-files -- \ '*.sh' \ )