From 09003f6c30c37cbebc39cc64b8246dfa720ea012 Mon Sep 17 00:00:00 2001 From: Carlos Tuñón Date: Sat, 19 Jan 2019 08:45:45 -0500 Subject: Fix crash on macOS and BSD with SpawnNewInstance action --- src/event.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 5c6b71d0..c3b5bb2d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -185,14 +185,17 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { fn spawn_new_instance(&mut self) { let alacritty = env::args().next().unwrap(); + #[cfg(unix)] - let args = [ - "--working-directory".into(), - fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) - .expect("shell working directory"), - ]; + let args = { + if let Ok(path) = fs::read_link(format!("/proc/{}/cwd", unsafe { tty::PID })) { + vec!["--working-directory".into(), path] + } else { + Vec::new() + } + }; #[cfg(not(unix))] - let args: [&str; 0] = []; + let args: Vec = Vec::new(); match start_daemon(&alacritty, &args) { Ok(_) => debug!("Started new Alacritty process: {} {:?}", alacritty, args), -- cgit