1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

allow using relative cwd for wezterm cli subcommands

refs: #1243
This commit is contained in:
Wez Furlong 2021-11-13 20:59:02 -07:00
parent da3296892e
commit f3a2e841ca
2 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -262,6 +262,18 @@ impl SetCwdCommand {
}
}
fn canon_cwd(cwd: Option<OsString>) -> anyhow::Result<Option<String>> {
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?;