Skip to content

Commit

Permalink
ShellCheck all shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Nov 10, 2024
1 parent b9e0549 commit 8002e57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 8 additions & 4 deletions scripts/build_otp_macos.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ build_openssl() {
return
fi

if [[ $version == 3* ]]; then
if [[ "$version" == 3* ]]; then
local ref_name="openssl-${version}"
else
local ref_name="OpenSSL_${version//./_}"
Expand All @@ -66,6 +66,7 @@ build_openssl() {
(
cd "${src_dir}"
git clean -dfx
# shellcheck disable=SC2086
./config no-shared --prefix="${rel_dir}" ${CFLAGS}
make
make install_sw
Expand Down Expand Up @@ -118,7 +119,7 @@ test_otp() {
{ok, _} = application:ensure_all_started(crypto), io:format("crypto ok~n"),
halt().'

if dyld_info ${OTP_DIR}/lib/crypto-*/priv/lib/crypto.so | tail -n +2 | grep -q openssl; then
if dyld_info "${OTP_DIR}/lib/crypto-*/priv/lib/crypto.so" | tail -n +2 | grep -q openssl; then
echo "error: openssl dynamically linked"
exit 1
fi
Expand All @@ -128,7 +129,7 @@ test_otp() {
wx:new(), io:format("wx ok~n"),
halt().'

if dyld_info ${OTP_DIR}/lib/wx-*/priv/wxe_driver.so | tail -n +2 | grep -q wxwidgets; then
if dyld_info "${OTP_DIR}/lib/wx-*/priv/wxe_driver.so" | tail -n +2 | grep -q wxwidgets; then
echo "error: wx dynamically linked"
exit 1
fi
Expand Down Expand Up @@ -188,7 +189,7 @@ build_otp() {
fi

if [[ "${WXWIDGETS_VERSION}" = disabled ]]; then
wxwidgets_flags=--without-{wx,observer,debugger,et}
wxwidgets_flags="--without-{wx,observer,debugger,et}"
else
wxwidgets_flags=""
fi
Expand All @@ -206,6 +207,7 @@ build_otp() {
;;
esac

# shellcheck disable=SC2086
./otp_build configure \
--build="${target}" \
--host="${target}" \
Expand All @@ -224,6 +226,7 @@ build_otp() {

export PATH="${rel_dir}/bin:${PATH}"

# shellcheck disable=SC2310
if ! test_otp; then
rm -rf "${rel_dir}"
fi
Expand All @@ -236,4 +239,5 @@ build_tgz() {
tar czf "${OTP_TGZ}" --cd "${OTP_DIR}" .
}

# shellcheck disable=SC2068
main $@
5 changes: 3 additions & 2 deletions scripts/update_builds.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ push() {
git checkout "${target_branch}"
git reset --hard "origin/${target_branch}"
git pull origin "${target_branch}"
build_sha256=$(shasum -a 256 $TGZ | cut -d ' ' -f 1)
build_sha256=$(shasum -a 256 "$TGZ" | cut -d ' ' -f 1)
date=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
mkdir -p builds/
touch "${BUILDS_CSV}"
sed -i.bak "/^${OTP_REF_NAME},/d" "${BUILDS_CSV}"
rm "${BUILDS_CSV}.bak"
echo -ne "${OTP_REF_NAME},${OTP_REF},${date},${build_sha256},openssl-${OPENSSL_VERSION},wxwidgets-${WXWIDGETS_VERSION}\n$(cat ${BUILDS_CSV})" > "${BUILDS_CSV}"
echo -ne "${OTP_REF_NAME},${OTP_REF},${date},${build_sha256},openssl-${OPENSSL_VERSION},wxwidgets-${WXWIDGETS_VERSION}\n$(cat "${BUILDS_CSV}")" > "${BUILDS_CSV}"
sort --reverse --unique -k1,1 -o "${BUILDS_CSV}" "${BUILDS_CSV}"
git add builds/
GIT_AUTHOR_NAME="${GITHUB_ACTOR}" \
Expand All @@ -53,4 +53,5 @@ push() {
git push origin "${target_branch}"
}

# shellcheck disable=SC2068
main $@
9 changes: 5 additions & 4 deletions scripts/upload.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ main() {
: "${ATTESTATION:=}"

if [[ -z "${OTP_REF+x}" ]]; then
OTP_REF=$(gh api repos/erlang/otp/commits/${OTP_REF_NAME} --jq .sha)
OTP_REF=$(gh api "repos/erlang/otp/commits/${OTP_REF_NAME}" --jq .sha)
fi

if [[ "${OTP_REF_NAME}" = master ]] || echo "${OTP_REF_NAME}" | grep -q "^maint"; then
Expand All @@ -38,8 +38,8 @@ main() {
else
if ! echo "${ref_name}" | grep -qE 'maint|master'; then
if [[ -f builds/aarch64-apple-darwin.csv ]]; then
latest_version=`cat builds/aarch64-apple-darwin.csv | cut -d"," -f1 | grep OTP- | sed 's/OTP-//' | sort --reverse -V | head -1`
version=$(echo "$ref_name" | sed 's/OTP-//')
latest_version=$(cut -d"," -f1 < builds/aarch64-apple-darwin.csv | grep OTP- | sed 's/OTP-//' | sort --reverse -V | head -1)
version=${ref_name/OTP-/}

if [[ $(printf "%s\n%s" "$latest_version" "$version" | sort --reverse -V | head -1) != "$latest_version" ]]; then
extra_flags="--latest"
Expand All @@ -56,7 +56,7 @@ main() {
--title "${ref_name}" \
--notes "${notes}" \
--target "${target}" \
${extra_flags} \
"${extra_flags}" \
"${ref_name}"
fi

Expand Down Expand Up @@ -107,4 +107,5 @@ main() {
--field target="${target}"
}

# shellcheck disable=SC2068
main $@

0 comments on commit 8002e57

Please sign in to comment.