From ed8b563f20e35a060dca5d058c9ba043a8a3ea2b Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 19 Sep 2023 09:15:34 +0800 Subject: [PATCH] fix: remote oh-my-zsh env var export issue (#528) * fix: fix remove oh-my-zsh env export issue --- src/steps/zsh.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/steps/zsh.rs b/src/steps/zsh.rs index faf1f619..6e913afd 100644 --- a/src/steps/zsh.rs +++ b/src/steps/zsh.rs @@ -181,10 +181,17 @@ pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> { .args([ "-c", // ` > /dev/null` is used in case the user's zshrc will have some stdout output. - format!("source {} > /dev/null && echo $ZSH", zshrc_path.display()).as_str(), + format!( + "source {} > /dev/null && export -p | grep ZSH > /dev/null && echo $ZSH", + zshrc_path.display() + ) + .as_str(), ]) .output_checked_utf8()?; - env::set_var("ZSH", output.stdout.trim()); + let zsh_env = output.stdout.trim(); + if !zsh_env.is_empty() { + env::set_var("ZSH", zsh_env); + } } let oh_my_zsh = env::var("ZSH")