diff --git a/docs/changelog.md b/docs/changelog.md index fdbb31d663c..25f50e01b4e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -72,6 +72,7 @@ As features stabilize some brief notes about them will accumulate here. * multiplexer: spawning remote tabs didn't correctly record local tab mapping, resulting in phantom additional tabs showing in the client. [#1222](https://github.com/wez/wezterm/issues/1222) * `wezterm ls-fonts --text "✘"` didn't account for the system fallback list. [#849](https://github.com/wez/wezterm/issues/849) * macOS: The `Menlo` font is now implicitly included in the system fallback list, as it is the only font that contains U+2718 ✘ +* `wezterm cli spawn --cwd ..` and `wezterm cli split-pane --cwd ..` now resolve relative paths [#1243](https://github.com/wez/wezterm/issues/1243) #### Updated and Improved diff --git a/wezterm/src/main.rs b/wezterm/src/main.rs index 44f3af4b49d..7edd5f839d6 100644 --- a/wezterm/src/main.rs +++ b/wezterm/src/main.rs @@ -262,6 +262,18 @@ impl SetCwdCommand { } } +fn canon_cwd(cwd: Option) -> anyhow::Result> { + match cwd { + None => Ok(None), + Some(cwd) => Ok(Some( + std::fs::canonicalize(cwd)? + .to_str() + .ok_or_else(|| anyhow!("path is not representable as String"))? + .to_string(), + )), + } +} + fn terminate_with_error_message(err: &str) -> ! { log::error!("{}; terminating", err); std::process::exit(1); @@ -448,7 +460,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: let builder = CommandBuilder::from_argv(prog); Some(builder) }, - command_dir: cwd.and_then(|c| c.to_str().map(|s| s.to_string())), + command_dir: canon_cwd(cwd)?, }) .await?; @@ -516,7 +528,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow: let builder = CommandBuilder::from_argv(prog); Some(builder) }, - command_dir: cwd.and_then(|c| c.to_str().map(|s| s.to_string())), + command_dir: canon_cwd(cwd)?, size: config::configuration().initial_size(), }) .await?;