Skip to content

fix(scripts): portable uppercase for branch-name acronym retention (bash 3.2)#3192

Open
PascalThuet wants to merge 2 commits into
github:mainfrom
PascalThuet:fix/branch-name-acronym-bash32
Open

fix(scripts): portable uppercase for branch-name acronym retention (bash 3.2)#3192
PascalThuet wants to merge 2 commits into
github:mainfrom
PascalThuet:fix/branch-name-acronym-bash32

Conversation

@PascalThuet

Copy link
Copy Markdown
Contributor

Description

Branch-name generation keeps short uppercase acronyms (e.g. AI) by re-checking the lowercased word against the original description with ${word^^}. That parameter expansion is bash 4+ only; on macOS's default bash 3.2 it errors with bad substitution, so the acronym / short-word retention branch never matches and those words are silently dropped (go AI now yields 001-now instead of 001-ai-now).

Replace ${word^^} with tr '[:lower:]' '[:upper:]', which is portable. Applies to both the core scripts/bash/create-new-feature.sh and the git extension's extensions/git/scripts/bash/create-new-feature-branch.sh. No behavior change on bash 4+.

CI runs on bash 4+/Linux, so the existing tests passed there; the bug only shows on the default macOS shell.

Testing

  • On macOS bash 3.2.57: test_branch_name_short_word_case_sensitivity and test_short_word_retention[go AI now-001-ai-now] now pass (they failed before this fix).
  • Full branch-naming suites green: test_timestamp_branches, test_git_extension, test_branch_numbering (99 passed, 35 skipped).
  • shellcheck --severity=error clean on both scripts.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

An AI coding agent surfaced the failing tests while running the suite on macOS and pinned the root cause (${word^^} vs bash 3.2); the fix was written and reviewed by me.

Branch-name generation keeps short uppercase acronyms (e.g. "AI") by re-checking
the lowercased word against the original description with ${word^^}. That
parameter expansion is bash 4+ only; on macOS's default bash 3.2 it errors with
"bad substitution", so the acronym/short-word retention branch never matches and
those words are dropped ("go AI now" yields 001-now instead of 001-ai-now). Use
tr '[:lower:]' '[:upper:]' instead, which is portable.

Applies to both the core create-new-feature.sh and the git extension's
create-new-feature-branch.sh. The existing
test_branch_name_short_word_case_sensitivity / test_short_word_retention tests
cover this and now pass on bash 3.2 (CI runs on bash 4+/Linux, so they passed
there already).

(Disclosure: an AI coding agent surfaced the failure while running the suite on
macOS and pinned the root cause; fix written and reviewed by me.)
@PascalThuet PascalThuet requested a review from mnriem as a code owner June 27, 2026 06:17
- core create-new-feature.sh: match the acronym with `grep -qw` (POSIX
  whole-word) instead of `\b...\b` (GNU/BSD-only), matching the git extension
  and dropping a non-POSIX construct.
- lint: add a CI guard rejecting bash 4+ case-modification expansions in *.sh.
  shellcheck assumes bash 4+ from the shebang and can't flag them, and CI has no
  bash-3.2 lane, so this prevents silently re-shipping the macOS regression this
  PR fixes.
- update a stale PowerShell extension comment that cited the removed bash idiom.

(Disclosure: prompted by an AI code review of the PR; written and reviewed by me.)
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