Skip to content

About

Fail when shell scripts use syntax the Bash shipped with macOS cannot run.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Bash 3.2 compatibility

GitHub Action that fails when shell scripts use syntax the Bash shipped with macOS cannot run. That Bash is 3.2.

bash -n on Bash 3.2 still accepts some Bash 4 commands, because names such as mapfile look like ordinary commands. This action rejects those tokens, then parses every selected script with Bash 3.2.

Usage

- uses: actions/checkout@v4

- uses: hellosign/bash32-action@v1
  with:
    paths: |
      bin/**
      scripts/**/*.sh

paths is newline-separated globs relative to the repository root. A file is checked when its shebang contains bash. Other files matched by a glob, including sh and PHP scripts, are skipped. Each glob must match at least one Bash script.

The runner needs Docker. GitHub-hosted runners already have it.

Inputs

Name Description Default
paths Newline-separated globs of files to consider. Required
bash-image Docker image that provides Bash 3.2. bash:3.2

What it rejects

Bash 4 and newer syntax that bash -n does not catch on Bash 3.2:

  • mapfile and readarray
  • declare -A
  • coproc
  • [[ -v
  • ${var^^}, ${var,,}, and ${var@Q}
  • negative array indexes such as ${arr[-1]}
  • &>> and |&

It also fails when Bash 3.2 itself cannot parse a script.

An empty array expanded under set -u ("${items[@]}" before any element is added) is a runtime error on Bash 3.2, not a parse error. This action does not execute the scripts, so it does not catch that case.

About

Fail when shell scripts use syntax the Bash shipped with macOS cannot run.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages