From 17103f872f89e93f8a766a0eb060e4dfe875469c Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Sun, 16 Feb 2020 15:59:10 +0200 Subject: [PATCH] Fix a possible panic with ZSH zinit --- src/steps/zsh.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/steps/zsh.rs b/src/steps/zsh.rs index f627bc9e..a7001e32 100644 --- a/src/steps/zsh.rs +++ b/src/steps/zsh.rs @@ -68,12 +68,15 @@ pub fn run_zinit(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { let zsh = require("zsh")?; let zshrc = zshrc(base_dirs).require()?; - env::var("ZPFX").map(PathBuf::from).unwrap().require()?; + let zinit_exists = env::var("ZPFX") + .map(PathBuf::from) + .unwrap_or_else(|_| base_dirs.home_dir().join(".zinit")) + .exists(); print_separator("zinit"); // Check whether this is a pre- or post- renaming installation - let zcommand = if Path::new(&base_dirs.home_dir().join(".zinit")).exists() { + let zcommand = if zinit_exists { "zinit" } else { "zplugin"