Skip to content

Remove dead array assignment that breaks .githelpers under dash#5

Merged
nonrational merged 1 commit into
mainfrom
fix-githelpers-dash-parse
Jun 16, 2026
Merged

Remove dead array assignment that breaks .githelpers under dash#5
nonrational merged 1 commit into
mainfrom
fix-githelpers-dash-parse

Conversation

@nonreagent

Copy link
Copy Markdown
Collaborator

What

Delete one dead line from switch_recent_branches_by_index in .githelpers:

 switch_recent_branches_by_index() {
-  local branches=($(list_branches_by_relative_commit | awk '{print $NF}'))
   local current_branch=$(git branch --show-current)

branches is assigned and then never read — the function pipes list_branches_by_relative_commit straight into fzf a few lines down. It's leftover from a pre-fzf implementation.

Why it matters

Git runs !-prefixed aliases through /bin/sh. On Debian/Ubuntu (and the exe.dev VMs), /bin/sh is dash. When an alias like git l does !. ~/.githelpers && pretty_git_log, dash sources the file — and dash parses the entire file before executing anything. The bash array literal name=(...) is the one bit of syntax dash can't parse, so it aborts:

$ git l
.githelpers: 228: Syntax error: "(" unexpected (expecting "}")

That isn't isolated to the fzf switcher — it takes down every alias that sources this file (l, b, bs, lb, opb, pb, …), since none of them get past the parse. Removing the dead line fixes all of them.

The [[ ]] uses elsewhere in the file parse fine under dash (they only fail at runtime, inside their own functions) — this array literal was the sole parse-level bashism.

Verification

dash -n .githelpers            # parses clean
sh -c '. ./.githelpers'        # sources OK (was: Syntax error)
bash -c '. ./.githelpers && type switch_recent_branches_by_index'   # fn still defined

No behavior change on systems where /bin/sh is bash — the line was dead there too.

🤖 Generated with Claude Code

switch_recent_branches_by_index assigns `local branches=(...)` but never
reads the variable — it was left behind when the function was rewired to
pipe list_branches_by_relative_commit straight into fzf.

The bash array literal is the only bashism that breaks *parsing* (not just
runtime). Since git runs `!`-prefixed aliases through /bin/sh, on systems
where /bin/sh is dash (Debian/Ubuntu default) dash parses the whole file
before running anything and aborts here with:

    .githelpers: Syntax error: "(" unexpected

That takes down every alias that sources this file (`git l`, `git b`,
`git lb`, …), not just the fzf switcher. Deleting the dead line restores
them and removes the cruft.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nonrational nonrational merged commit eb52f99 into main Jun 16, 2026
1 check passed
nonreagent added a commit to nonreagent/dotfiles that referenced this pull request Jun 16, 2026
Re-vendored from upstream main after nonrational/dotfiles#5 merged. Removes
the dead `local branches=(...)` array assignment whose bash-only syntax made
dash abort parsing the whole file — which broke every git alias that sources
~/.githelpers (l, b, lb, …) since /bin/sh is dash on this VM.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nonreagent nonreagent deleted the fix-githelpers-dash-parse branch June 21, 2026 18:28
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.

2 participants