Skip to content

feat: zsh support — port hub/account-for-org + test/CI under zsh#1

Merged
alexzhangs merged 2 commits into
mainfrom
feature/zsh-support
Jun 14, 2026
Merged

feat: zsh support — port hub/account-for-org + test/CI under zsh#1
alexzhangs merged 2 commits into
mainfrom
feature/zsh-support

Conversation

@alexzhangs

Copy link
Copy Markdown
Contributor

Summary

Makes the git library run under zsh (the default shell on modern macOS), in addition to bash. xsh executes imported utilities under zsh's ksh emulation. The hub/* utilities are nearly portable already — this PR has one code fix plus test/CI wiring for both shells.

Companion to alexzhangs/xsh#32 (framework zsh support).

Code

  • hub/account-for-org: read -ra (array read) is bash-only — zsh's read has no -a (and -A differs), so the util produced bad option: -a and never matched under zsh. Replaced with a comma→space substitution + word split, which is portable (org names never contain spaces).

The other utilities (account-for-email, account-for-repo, run) and the hub/ssh script need no changes: no array-read, no FUNCNAME, no ${!var} indirection, and their nested xsh calls are already captured in $() so a nested getopts can't corrupt the caller's OPTIND.

Tests

  • test.sh now self-sources ~/.xshrc when xsh isn't already a function, so it runs as a child of either shell (under bash xsh is inherited as an exported function; zsh can't export functions).
  • CI (.github/workflows/ci-unittest.yml) gains a shell: [bash, zsh] matrix dimension (installs zsh on Linux).

Locally: all 25 test.sh assertions pass under both zsh 5.9 and macOS bash 3.2.57.

Sequencing

The zsh CI jobs are continue-on-error for now: they install xsh from alexzhangs/xsh master, which doesn't carry zsh support yet, so they stay red until that release. Remove continue-on-error once a zsh-supporting xsh is released to master.

🤖 Generated with Claude Code

alexzhangs and others added 2 commits June 14, 2026 16:14
xsh runs imported utilities under zsh's ksh emulation. The hub/* utilities
are nearly portable already; the one fix:

- hub/account-for-org: `read -ra` (array read) is bash-only — zsh's read has
  no -a (and -A differs). Replaced with a comma->space substitution + word
  split, which is portable (org names never contain spaces).

The other utilities (account-for-email, account-for-repo, run) and the ssh
wrapper need no changes: they use no array-read, no FUNCNAME, no ${!var}
indirection, and their nested xsh calls are already captured in $() so the
nested getopts can't corrupt the caller's OPTIND.

test.sh now self-sources ~/.xshrc when xsh isn't already a function, so it
runs as a child of either shell (under bash xsh is inherited as an exported
function; zsh can't export functions). CI ci-unittest.yml gains a
`shell: [bash, zsh]` matrix dimension (installs zsh on Linux); the zsh jobs
are continue-on-error until a zsh-supporting xsh is released to master.

Verified: all 25 test.sh assertions pass under both zsh 5.9 and macOS bash
3.2.57.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexzhangs alexzhangs merged commit dd2eae4 into main Jun 14, 2026
8 checks passed
@alexzhangs alexzhangs deleted the feature/zsh-support branch June 14, 2026 10:18
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