feat: zsh support — port hub/account-for-org + test/CI under zsh#1
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sreadhas no-a(and-Adiffers), so the util producedbad option: -aand 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 thehub/sshscript need no changes: no array-read, noFUNCNAME, no${!var}indirection, and their nestedxshcalls are already captured in$()so a nested getopts can't corrupt the caller's OPTIND.Tests
test.shnow self-sources~/.xshrcwhenxshisn't already a function, so it runs as a child of either shell (under bashxshis inherited as an exported function; zsh can't export functions)..github/workflows/ci-unittest.yml) gains ashell: [bash, zsh]matrix dimension (installs zsh on Linux).Locally: all 25
test.shassertions pass under both zsh 5.9 and macOS bash 3.2.57.Sequencing
The zsh CI jobs are
continue-on-errorfor now: they install xsh fromalexzhangs/xshmaster, which doesn't carry zsh support yet, so they stay red until that release. Removecontinue-on-erroronce a zsh-supporting xsh is released to master.🤖 Generated with Claude Code