From 3742071a9be5dea91c95fc820935e594a9e8e7e0 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 5 Mar 2020 08:07:54 -0800 Subject: [PATCH] improve OSC 7 / cwd handling when dir doesn't exist Hadn't noticed this until just now because the systems I've been using have all had a pretty similar filesystem layout. This commit avoids a failure to spawn a child process when the desired directory doesn't exist locally. --- src/mux/domain.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mux/domain.rs b/src/mux/domain.rs index 59119e98c..633005332 100644 --- a/src/mux/domain.rs +++ b/src/mux/domain.rs @@ -112,7 +112,13 @@ impl Domain for LocalDomain { None => config.build_prog(None)?, }; if let Some(dir) = command_dir { - cmd.cwd(dir); + // I'm not normally a fan of existence checking, but not checking here + // can be painful; in the case where a tab is local but has connected + // to a remote system and that remote has used OSC 7 to set a path + // that doesn't exist on the local system, process spawning can fail. + if std::path::Path::new(&dir).exists() { + cmd.cwd(dir); + } } let pair = self.pty_system.openpty(size)?; let child = pair.slave.spawn_command(cmd)?;