From a7f3c6040cd2a9aba2c45099b56e2c1f36285854 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 29 Mar 2020 14:15:38 -0700 Subject: [PATCH] fixup! fixup! Add POSIX shell support --- src/subcommand/init.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/subcommand/init.rs b/src/subcommand/init.rs index 4c8039a..0e662bf 100644 --- a/src/subcommand/init.rs +++ b/src/subcommand/init.rs @@ -38,21 +38,20 @@ impl Init { let stdout = io::stdout(); let mut handle = stdout.lock(); - writeln!(handle, "{}", config.z)?; + // If any `writeln!` call fails to write to stdout, we assume the user's + // computer is on fire and panic. + writeln!(handle, "{}", config.z).unwrap(); if !self.no_define_aliases { - writeln!(handle, "{}", config.alias)?; + writeln!(handle, "{}", config.alias).unwrap(); } match self.hook { Hook::none => (), - Hook::prompt => writeln!(handle, "{}", config.hook.prompt)?, - Hook::pwd => { - if let Some(pwd_hook) = config.hook.pwd { - writeln!(handle, "{}", pwd_hook)?; - } else { - bail!("PWD hooks are currently unsupported on this shell."); - } - } + Hook::prompt => writeln!(handle, "{}", config.hook.prompt).unwrap(), + Hook::pwd => match config.hook.pwd { + Some(pwd_hook) => writeln!(handle, "{}", pwd_hook).unwrap(), + None => bail!("PWD hooks are currently unsupported on this shell."), + }, } Ok(())