mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Fix zsh alias quoting in sourced shell snapshots (#48187)
## Why Sourced snapshots parse options and aliases as a group before restored options take effect. Aliases serialized with `RC_QUOTES` enabled can therefore be misinterpreted by the replay shell. ## What changed Serialize zsh aliases for sourced snapshots with `NO_RC_QUOTES` in a subshell, preserving the captured shell options and avoiding a dependency on the optional `zsh/parameter` module. ## Testing Extend regression coverage to execute restored aliases with `RC_QUOTES` enabled and disabled across source and eval replay. Expand macOS zsh concurrent replay tests to cover quoted aliases, preserved options, and blocked descriptor paths with and without a TTY. GitOrigin-RevId: 48086f380c21318bece9226dfe6486c179c2a440
This commit is contained in:
@@ -88,6 +88,13 @@ fn capture_script(
|
||||
script
|
||||
.replace("SNAPSHOT_OPTIONS_BEGIN", match replay { Replay::Eval => "", Replay::Source => "printf '{\\n'" })
|
||||
.replace("SNAPSHOT_ALIASES_END", match replay { Replay::Eval => "", Replay::Source => "printf \"case '' in '') ;; esac\\n}\\n\"" })
|
||||
// The source group is parsed before its options take effect. Serialize
|
||||
// aliases with the replay shell's initial quoting rules, not RC_QUOTES.
|
||||
// setopt works without the optional zsh/parameter module.
|
||||
.replace("SNAPSHOT_ZSH_ALIASES", match replay {
|
||||
Replay::Eval => "\\alias -L",
|
||||
Replay::Source => "(\\setopt NO_RC_QUOTES; \\alias -L)",
|
||||
})
|
||||
.replace("SNAPSHOT_EXPORTS", &declarations)
|
||||
.replace(
|
||||
"SNAPSHOT_DECLARATION_ENVIRONMENT",
|
||||
@@ -133,7 +140,7 @@ print ''
|
||||
printf '\0'
|
||||
alias_count=$(\alias -L | __codex_snapshot_command wc -l | __codex_snapshot_command tr -d ' ')
|
||||
print "# aliases $alias_count"
|
||||
\alias -L
|
||||
SNAPSHOT_ZSH_ALIASES
|
||||
print ''
|
||||
SNAPSHOT_ALIASES_END
|
||||
printf '\0'
|
||||
|
||||
Reference in New Issue
Block a user