From 60ea708429bd6f0d0682523b36fc7e25fe08d84e Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Aug 2021 10:47:19 +0200 Subject: [PATCH 1/3] Use shfmt to 3.3.1 when linting locally --- scripts/lint | 2 +- scripts/lint.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint b/scripts/lint index d8cf575..ed1c230 100755 --- a/scripts/lint +++ b/scripts/lint @@ -11,7 +11,7 @@ echo '# Linting shell scripts' if ! docker --version >/dev/null 2>/dev/null; then echo 'Docker is not installed, or it is not running.' >&2 rc=1 -elif ! docker run --rm -v "$SRC_DIR:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.0.1 fix; then +elif ! docker run --rm -v "$SRC_DIR:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.3.1 fix; then echo 'ERROR!' >&2 rc=1 fi diff --git a/scripts/lint.bat b/scripts/lint.bat index fe709b7..c93520a 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -16,7 +16,7 @@ if errorlevel 1 ( echo Docker is not installed, or it's not running >&2 set rc=1 ) else ( - docker run --rm -v "%SRC_DIR%:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.0.1 fix + docker run --rm -v "%SRC_DIR%:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.3.1 fix if errorlevel 1 ( echo ERROR! >&2 set rc=1 From 0f0a07c7fe59110f76c9d5375f2be90131291641 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Aug 2021 11:41:35 +0200 Subject: [PATCH 2/3] Test all posix scripts --- scripts/invoke-shfmt | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/scripts/invoke-shfmt b/scripts/invoke-shfmt index b071c2c..ec97e0e 100755 --- a/scripts/invoke-shfmt +++ b/scripts/invoke-shfmt @@ -3,28 +3,38 @@ set -o errexit set -o nounset -PARAMS='-s -ln posix -i 0 -ci -kp' +. ./scripts/common + +# -s Simplify the code +# -ln posix Language variant: POSIX +# -i 0 Use TAB to indent +# -ci Switch cases will be indented +# -kp Keep column alignment paddings +DPEI_PARAMS='-s -ln posix -i 0 -ci -kp' case "${1:-}" in check) - PARAMS="$PARAMS -d" + DPEI_PARAMS="$DPEI_PARAMS -d" ;; fix) - PARAMS="$PARAMS -w" + DPEI_PARAMS="$DPEI_PARAMS -w" ;; *) - printf 'Syntax: %s ' "$0" >&2 + printf 'Syntax: %s \n' "$0" >&2 exit 1 ;; esac -shfmt $PARAMS \ - install-php-extensions \ - scripts/ci-filter-supported-extensions \ - scripts/ci-retrieve-recent-extensions \ - scripts/ci-test-extensions \ - scripts/common \ - scripts/invoke-shfmt \ - scripts/lint \ - scripts/test-restore-apt \ - scripts/update-readme +DPEI_FILES=install-php-extensions + +IFS=' +' +for DPEI_FILE in $(find scripts -type f); do + if test "$(head -n1 $DPEI_FILE)" = '#!/bin/sh'; then + DPEI_FILES="$DPEI_FILES $DPEI_FILE" + fi +done + +resetIFS + +FORCE_COLOR=true shfmt $DPEI_PARAMS -- $DPEI_FILES From 239f38729d5b4d1c4638e4195bd86fb92e70e4ec Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 11 Aug 2021 11:43:38 +0200 Subject: [PATCH 3/3] Fix shell coding style --- scripts/test-installcomposer | 24 ++++++++++++------------ scripts/test-installversion | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/test-installcomposer b/scripts/test-installcomposer index 0ba2757..0ef1b84 100755 --- a/scripts/test-installcomposer +++ b/scripts/test-installcomposer @@ -7,24 +7,24 @@ set -o nounset WANTED_VERSION="${1:-}" INSTALLME=@composer if test -n "$WANTED_VERSION"; then - INSTALLME="$INSTALLME-$1" + INSTALLME="$INSTALLME-$1" fi CI=true ./install-php-extensions "$INSTALLME" INSTALLED_VERSION="$(composer --version | sed -E 's/^.*[Vv]ersion\s*(\S+).*$/\1/')" if test -z "$WANTED_VERSION"; then - echo 'Installing the latest version worked' + echo 'Installing the latest version worked' elif printf '%s' "$WANTED_VERSION" | grep -Eq '^[0-9]+$'; then - if test "${INSTALLED_VERSION#$WANTED_VERSION.}" = "$INSTALLED_VERSION"; then - printf 'Installing major version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" - exit 1 - fi - printf 'Installing major version %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" + if test "${INSTALLED_VERSION#$WANTED_VERSION.}" = "$INSTALLED_VERSION"; then + printf 'Installing major version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" + exit 1 + fi + printf 'Installing major version %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" else - if test "$INSTALLED_VERSION" != "$WANTED_VERSION"; then - printf 'Installing specific version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" - exit 1 - fi - printf 'Installing specific version %s worked\n' "$INSTALLED_VERSION" + if test "$INSTALLED_VERSION" != "$WANTED_VERSION"; then + printf 'Installing specific version %s DID NOT worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" + exit 1 + fi + printf 'Installing specific version %s worked\n' "$INSTALLED_VERSION" fi diff --git a/scripts/test-installversion b/scripts/test-installversion index b9d7799..3114d99 100755 --- a/scripts/test-installversion +++ b/scripts/test-installversion @@ -8,19 +8,19 @@ WANTED_VERSION="${1:-}" WANTED_VERSION_AFTERCARET="${1#^}" INSTALLME=xdebug if test -n "$WANTED_VERSION"; then - INSTALLME="$INSTALLME-$1" + INSTALLME="$INSTALLME-$1" fi CI=true ./install-php-extensions "$INSTALLME" INSTALLED_VERSION="$(php --ri xdebug | grep -Ei 'Version\s*=>\s*' | sed -E 's/^.*?=>\s*//')" if test -z "$WANTED_VERSION"; then - printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION" + printf 'Installing the default version worked (we installed version %s)\n' "$INSTALLED_VERSION" elif test "$WANTED_VERSION" = "$INSTALLED_VERSION"; then - printf 'Installing specific version %s worked\n' "$WANTED_VERSION" + printf 'Installing specific version %s worked\n' "$WANTED_VERSION" elif test "$WANTED_VERSION" != "$WANTED_VERSION_AFTERCARET" && test "${INSTALLED_VERSION#$WANTED_VERSION_AFTERCARET.}" != "$INSTALLED_VERSION"; then - printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" + printf 'Installing version compatible with %s worked (we installed version %s)\n' "$WANTED_VERSION" "$INSTALLED_VERSION" else - printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2 - exit 1 + printf 'We wanted to install version %s, but we installed %s\n' "$WANTED_VERSION" "$INSTALLED_VERSION" >&2 + exit 1 fi