Skip to content

Fix bash 3.2 compatibility#23

Open
jnasbyupgrade wants to merge 2 commits intoPostgres-Extensions:masterfrom
jnasbyupgrade:linux-compat
Open

Fix bash 3.2 compatibility#23
jnasbyupgrade wants to merge 2 commits intoPostgres-Extensions:masterfrom
jnasbyupgrade:linux-compat

Conversation

@jnasbyupgrade
Copy link
Contributor

@jnasbyupgrade jnasbyupgrade commented Mar 19, 2026

Related pgxntool-test PR: Postgres-Extensions/pgxntool-test#12

Changes

bash 3.2 syntax fix (pgtle.sh)

  • Replace ${#ARRAY[@]:-0} with ${#ARRAY[@]} throughout pgtle.sh
  • ${#ARRAY[@]:-0} is a fatal syntax error ("bad substitution") in bash 3.2 — the :- default modifier cannot be applied to an array length expression
  • ${#ARRAY[@]} correctly returns 0 for empty arrays in all bash versions

DOCS deduplication (base.mk)

  • Deduplicate DOCS when adding generated HTML, preventing duplicate install entries when HTML is already included by the wildcard

Shebang portability (all shell scripts)

  • Replace #!/bin/bash with #!/usr/bin/env bash in pgtle.sh, build_meta.sh, and lib.sh
  • /bin/bash fails on systems where bash lives elsewhere (some BSDs, NixOS, Homebrew on macOS)

- Replace `${#ARRAY[@]:-0}` with `${#ARRAY[@]}` throughout `pgtle.sh`;
  the `:-` default modifier is a syntax error ("bad substitution") in bash 3.2
- Deduplicate `DOCS` in `base.mk` when adding generated HTML to prevent
  duplicate install entries when HTML is already included by wildcard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Avoids hardcoding /bin/bash which breaks on systems where bash lives
elsewhere (some BSDs, NixOS, Homebrew on macOS). Documents the rule
in CLAUDE.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant