mirror of
https://github.com/stablyai/orca.git
synced 2026-09-28 00:02:41 +00:00
fix(omp): quote shell patterns against zsh global aliases
This commit is contained in:
@@ -39,8 +39,8 @@ __orca_restore_agent_teams_path
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ __orca_deferred_init() {
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ __orca_restore_agent_teams_path
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ __orca_deferred_init() {
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ fi
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ __orca_deferred_init() {
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
__complete|acp|agents|auth-broker|auth-gateway|bench|commit|completions|config|dry-balance|gallery|grep|grievances|install|join|models|plugin|read|say|search|setup|shell|ssh|stats|tiny-models|token|ttsr|update|usage|worktree|q|wt) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
'__complete'|'acp'|'agents'|'auth-broker'|'auth-gateway'|'bench'|'commit'|'completions'|'config'|'dry-balance'|'gallery'|'grep'|'grievances'|'install'|'join'|'models'|'plugin'|'read'|'say'|'search'|'setup'|'shell'|'ssh'|'stats'|'tiny-models'|'token'|'ttsr'|'update'|'usage'|'worktree'|'q'|'wt') return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -68,3 +68,28 @@ describe.skipIf(process.platform === 'win32')('omp wrapper under a user alias na
|
||||
expectAliasedOmpNameSurvives('/bin/zsh', 'setopt aliases')
|
||||
})
|
||||
})
|
||||
|
||||
describe.skipIf(process.platform === 'win32' || !zshAvailable)('OMP wrapper global aliases', () => {
|
||||
it.each(['--help', '-v', 'models'])('parses with hostile global alias %s', (token) => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'orca-omp-global-alias-'))
|
||||
roots.push(root)
|
||||
const startup = join(root, 'startup.zsh')
|
||||
writeFileSync(
|
||||
startup,
|
||||
[
|
||||
`alias -g -- ${token}='${token} 2>&1 | cat'`,
|
||||
getPosixOmpShellWrapper(),
|
||||
`__orca_omp_should_skip_extension '${token}'`,
|
||||
'printf "parsed\\n"',
|
||||
`alias -g -- '${token}'`
|
||||
].join('\n')
|
||||
)
|
||||
const result = spawnSync('/bin/zsh', ['-f', startup], {
|
||||
encoding: 'utf8',
|
||||
env: { ...process.env, HOME: root, ZDOTDIR: root }
|
||||
})
|
||||
expect(result.status, result.stderr).toBe(0)
|
||||
expect(result.stdout).toContain('parsed')
|
||||
expect(result.stdout).toContain('2>&1 | cat')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -40,13 +40,13 @@ const OMP_SUBCOMMANDS = [
|
||||
] as const
|
||||
|
||||
export function getPosixOmpShellWrapper(): string {
|
||||
const subcommands = OMP_SUBCOMMANDS.join('|')
|
||||
const subcommands = OMP_SUBCOMMANDS.map((value) => `'${value}'`).join('|')
|
||||
return `# Why: OMP does not auto-load Orca's managed status extension; wrap only
|
||||
# interactive launch invocations so subcommands such as \`omp config\` keep
|
||||
# their normal argv shape.
|
||||
__orca_omp_should_skip_extension() {
|
||||
case "\${1:-}" in
|
||||
help|--help|-h|--version|-v) return 0 ;;
|
||||
'help'|'--help'|'-h'|'--version'|'-v') return 0 ;;
|
||||
${subcommands}) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user