From 5dabe55947090c5382ee346b250eee391e4eebb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20W=C3=B6lzer?= <martin@libclapp.org>
Date: Mon, 16 Sep 2024 20:48:46 +0200
Subject: [PATCH] .ci/format/apply_shfmt.sh: introduced file

---
 .ci/format/apply_shfmt.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100755 .ci/format/apply_shfmt.sh

diff --git a/.ci/format/apply_shfmt.sh b/.ci/format/apply_shfmt.sh
new file mode 100755
index 00000000..8b0465d7
--- /dev/null
+++ b/.ci/format/apply_shfmt.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+if [ -z "${SHFMT_BIN}" ]; then
+    SHFMT_BIN="shfmt"
+fi
+
+if ! command -v "${SHFMT_BIN}" >/dev/null 2>&1; then
+    echo "ERROR: Binary '${SHFMT_BIN}' does not exist, please set the environment variable SHFMT_BIN to the correct shfmt version."
+    exit 1
+fi
+
+format_command="${SHFMT_BIN} -w -i 4"
+
+apply_format_script="$(dirname "${BASH_SOURCE[0]}")/apply_format.sh"
+
+files_regex=".*\.sh$"
+
+if ! "${apply_format_script}" --format-command "${format_command}" --files-regex "${files_regex}" "$@"; then
+    echo "ERROR: Executing '${apply_format_script}' failed."
+    exit 1
+fi
-- 
GitLab