fix: omz remote execution if ZSH is not present (#592)
This commit is contained in:
@@ -181,16 +181,20 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.args([
|
.args([
|
||||||
"-c",
|
"-c",
|
||||||
// ` > /dev/null` is used in case the user's zshrc will have some stdout output.
|
// ` > /dev/null` is used in case the user's zshrc will have some stdout output.
|
||||||
format!(
|
format!("source {} > /dev/null && export -p", zshrc_path.display()).as_str(),
|
||||||
"source {} > /dev/null && export -p | grep ZSH > /dev/null && echo $ZSH",
|
|
||||||
zshrc_path.display()
|
|
||||||
)
|
|
||||||
.as_str(),
|
|
||||||
])
|
])
|
||||||
.output_checked_utf8()?;
|
.output_checked_utf8()?;
|
||||||
let zsh_env = output.stdout.trim();
|
|
||||||
if !zsh_env.is_empty() {
|
let stdout = output.stdout;
|
||||||
env::set_var("ZSH", zsh_env);
|
|
||||||
|
let prefix = "export ZSH=";
|
||||||
|
for line in stdout.lines() {
|
||||||
|
if line.contains(prefix) {
|
||||||
|
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