@@ -179,25 +179,15 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
// children processes won't get it either, so we source the zshrc and set
|
// children processes won't get it either, so we source the zshrc and set
|
||||||
// the ZSH variable for topgrade here.
|
// the ZSH variable for topgrade here.
|
||||||
if ctx.under_ssh() {
|
if ctx.under_ssh() {
|
||||||
let zshrc_path = zshrc().require()?;
|
let res_env_zsh = Command::new("zsh")
|
||||||
let output = Command::new("zsh")
|
.args(["-ic", "print -rn -- ${ZSH:?}"])
|
||||||
.args([
|
.output_checked_utf8();
|
||||||
"-c",
|
|
||||||
// ` > /dev/null` is used in case the user's zshrc will have some stdout output.
|
|
||||||
format!("source {} > /dev/null && export -p", zshrc_path.display()).as_str(),
|
|
||||||
])
|
|
||||||
.output_checked_utf8()?;
|
|
||||||
|
|
||||||
let stdout = output.stdout;
|
// this command will fail if `ZSH` is not set
|
||||||
|
if let Ok(output) = res_env_zsh {
|
||||||
let prefix = "export ZSH=";
|
let env_zsh = output.stdout;
|
||||||
for line in stdout.lines() {
|
debug!("Oh-my-zsh: under SSH, setting ZSH={}", env_zsh);
|
||||||
if line.contains(prefix) {
|
env::set_var("ZSH", env_zsh);
|
||||||
let zsh_env = line.trim_start_matches(prefix);
|
|
||||||
debug!("Oh-my-zsh: under SSH, setting ZSH={}", zsh_env);
|
|
||||||
env::set_var("ZSH", zsh_env);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user