mislav/hub · error
alias starting with ! can't be split
Error message
alias starting with ! can't be split
What it means
Aliases whose command string begins with `!` denote shell (external) commands, which splitAliasCmd intentionally refuses to split into gh arguments. Invoking such an alias returns this error so the shell form can be handled elsewhere rather than mis-tokenized.
Source
Thrown at commands/runner.go:163
}
}
func isBuiltInHubCommand(command string) bool {
for hubCommand := range CmdRunner.All() {
if hubCommand == command {
return true
}
}
return false
}
func splitAliasCmd(cmd string) ([]string, error) {
if cmd == "" {
return nil, fmt.Errorf("alias can't be empty")
}
if strings.HasPrefix(cmd, "!") {
return nil, fmt.Errorf("alias starting with ! can't be split")
}
words, err := shellquote.Split(cmd)
if err != nil {
return nil, err
}
return words, nil
}
View on GitHub (pinned to 5c547ed804)
Solutions
- Remove the leading `!` and set a plain gh command alias: `gh alias set <name> 'pr list'`.
- If a shell command is needed, define a real shell alias/function or script instead of a gh alias.
- Delete the alias if it's obsolete: `gh alias delete <name>`.
Example fix
// before gh alias set deploy "!./deploy.sh" // after: run the script directly in your shell, or gh alias set deploy "workflow run deploy"
Defensive patterns
Strategy: validation
Validate before calling
if strings.HasPrefix(aliasBody, "!") {
return fmt.Errorf("alias %q uses shell syntax (!); gh aliases accept only gh commands", aliasName)
} Prevention
- Don't prefix gh alias values with `!`.
- Use shell aliases/functions for external commands instead.
- Migrate any git-style !aliases when moving to gh.
When it happens
Trigger: Invoking a gh alias whose stored value starts with `!` (e.g. `gh alias set say '!echo hi'`) — expandAlias passes "!echo hi" to splitAliasCmd, which rejects it via the strings.HasPrefix(cmd, "!") check.
Common situations: User set up a shell-escape alias expecting gh to run it; config copied from another tool (like git) where `!` aliases are supported; version differences where shell aliases were deprecated in gh.
Related errors
- alias can't be empty
- Error: couldn't detect shell type. Please specify your shell
- hub alias: unsupported shell supported shells: %s
- Unsupported flag -b when checking out pull request
- Unsupported flag --orphan when checking out pull request
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/d618703a884cc2b2.
Report an issue: GitHub.