feat: add shell snapshot for shell command (#7786)

This commit is contained in:
jif-oai
2025-12-11 13:46:43 +00:00
committed by GitHub
Unverified
parent b2280d6205
commit 29381ba5c2
14 changed files with 301 additions and 129 deletions
-27
View File
@@ -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)]