mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
feat: add shell snapshot for shell command (#7786)
This commit is contained in:
committed by
GitHub
Unverified
parent
b2280d6205
commit
29381ba5c2
@@ -63,33 +63,6 @@ impl Shell {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn wrap_command_with_snapshot(&self, command: &[String]) -> Vec<String> {
|
||||
let Some(snapshot) = &self.shell_snapshot else {
|
||||
return command.to_vec();
|
||||
};
|
||||
|
||||
if command.is_empty() {
|
||||
return command.to_vec();
|
||||
}
|
||||
|
||||
match self.shell_type {
|
||||
ShellType::Zsh | ShellType::Bash | ShellType::Sh => {
|
||||
let mut args = self.derive_exec_args(". \"$0\" && exec \"$@\"", false);
|
||||
args.push(snapshot.path.to_string_lossy().to_string());
|
||||
args.extend_from_slice(command);
|
||||
args
|
||||
}
|
||||
ShellType::PowerShell => {
|
||||
let mut args =
|
||||
self.derive_exec_args("param($snapshot) . $snapshot; & @args", false);
|
||||
args.push(snapshot.path.to_string_lossy().to_string());
|
||||
args.extend_from_slice(command);
|
||||
args
|
||||
}
|
||||
ShellType::Cmd => command.to_vec(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user