1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 03:09:06 +03:00

Avoid full path canonicalization when resolving cwd

It can have some surprising effects, so leave it at the basic logical
composition of cwd + relative rather than physical.

refs: https://github.com/wez/wezterm/issues/2449
This commit is contained in:
Wez Furlong 2022-08-23 09:55:45 -07:00
parent a8b1b6bd88
commit 57b10ac094
2 changed files with 10 additions and 8 deletions

View File

@ -36,6 +36,7 @@ As features stabilize some brief notes about them will accumulate here.
* `x` and `+` buttons in the fancy tab bar are now always square [#2399](https://github.com/wez/wezterm/issues/2399)
* middle clicking a tab to close it will now confirm closing using the same rules as [CloseCurrentTab](config/lua/keyassignment/CloseCurrentTab.md) [#2350](https://github.com/wez/wezterm/issues/2350)
* Emitting the tmux-style `ESC k TITLE ST` sequence via ConPTY breaks output for the pane [#2442](https://github.com/wez/wezterm/issues/2442)
* Avoid using full path canonicalization for `--cwd` options [#2449](https://github.com/wez/wezterm/issues/2449)
### 20220807-113146-c2fee766

View File

@ -442,10 +442,10 @@ struct SetCwdCommand {
impl SetCwdCommand {
fn run(&self) -> anyhow::Result<()> {
let cwd: std::path::PathBuf = match self.cwd.as_ref() {
Some(d) => std::fs::canonicalize(d)?,
None => std::env::current_dir()?,
};
let mut cwd = std::env::current_dir()?;
if let Some(dir) = &self.cwd {
cwd.push(dir);
}
let mut url = url::Url::from_directory_path(&cwd)
.map_err(|_| anyhow::anyhow!("cwd {} is not an absolute path", cwd.display()))?;
@ -462,11 +462,12 @@ impl SetCwdCommand {
}
}
fn canon_cwd(cwd: Option<OsString>) -> anyhow::Result<Option<String>> {
fn resolve_relative_cwd(cwd: Option<OsString>) -> anyhow::Result<Option<String>> {
match cwd {
None => Ok(None),
Some(cwd) => Ok(Some(
std::fs::canonicalize(cwd)?
std::env::current_dir()?
.join(cwd)
.to_str()
.ok_or_else(|| anyhow!("path is not representable as String"))?
.to_string(),
@ -1003,7 +1004,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
let builder = CommandBuilder::from_argv(prog);
Some(builder)
},
command_dir: canon_cwd(cwd)?,
command_dir: resolve_relative_cwd(cwd)?,
move_pane_id,
})
.await?;
@ -1098,7 +1099,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
let builder = CommandBuilder::from_argv(prog);
Some(builder)
},
command_dir: canon_cwd(cwd)?,
command_dir: resolve_relative_cwd(cwd)?,
size,
workspace,
})