Enforce shell linting/formatting and modernize scripts#657
Merged
runesoerensen merged 23 commits intomainfrom Mar 16, 2026
Merged
Enforce shell linting/formatting and modernize scripts#657runesoerensen merged 23 commits intomainfrom
runesoerensen merged 23 commits intomainfrom
Conversation
No need to resolve via `cd && pwd`
In `bin/compile`, also rename Go cache variable to `GO_CACHE_DIR`
edmorley
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add shell script linting (ShellCheck) and formatting (shfmt) enforcement, and modernize all shell scripts to follow consistent conventions.
Linting & formatting infrastructure
.shellcheckrcwithenable=allfor maximum strictness.editorconfigconfiguring shfmt (tabs,binary_next_line,switch_case_indent,shell_variant=bash)lint(meta),lint-scripts(ShellCheck),check-format/format(shfmt)lintjob to GitHub Actions CI (ShellCheck + shfmt)test/shunit2.shfrom both linting and formatting.editorconfigand.shellcheckrctobuildpack.tomlpublish ignore listShellCheck fixes
$var->"${var}")[ ]with[[ ]]for bash-specific tests-a/-ocompound tests with&&/||[ ! -zwith[[ -n# shellcheck disable=directives for intentional patterns (e.g. word-splitting of$pkgs, dynamically sourced files)shfmt formatting
<<-requirement)switch_case_indent,binary_next_lineformatting rules>,>>,<,&>)Shell script modernization
#!/usr/bin/env bashacross all scripts (including convertingsbin/add-versionfrom#!/bin/shand adding a shebang totest/utils.sh)BUILDPACK_DIR: Replace$0-based path resolution withBASH_SOURCE[0]pattern (BUILDPACK_DIR=$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)) — more reliable when sourced, and lets ShellCheck follow source paths without# shellcheck source=hintsset -euo pipefail: Enable strict error handling everywhere (-ufor unset variable detection,-o pipefailfor pipeline failures). Add:-defaults to all optional/environment variables (${GOVERSION:-},${GO_INSTALL_PACKAGE_SPEC:-}, etc.)sourcedependencies: Moveoutput.shsourcing out ofcommon.shinto each caller, making dependency chains visiblemkdir -p "$1" "$2"(platform guarantees dirs exist),cd "$1/" && pwdcanonicalization (platform passes absolute paths), and a broken no-oppushd/popdintest/run.shbuild->BUILD_DIRenv_dir->ENV_DIRcache_root->CACHE_DIRcache->GO_CACHE_DIR(the namespaced.heroku/gosubdirectory)buildpack/testpack->BUILDPACK_DIRGUS-W-21598655