Fix relative CWD path given on command line being interpreted as within the server's CWD

This commit is contained in:
kas authored and Wez Furlong committed 2022-11-19 08:11:13 -08:00
1 parent d3d1db8663
commit 74e55d09e1
2 files changed
+9 -2

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ use clap::builder::ValueParser;
use clap::{Parser, ValueHint};
use config::{Dimension, GeometryOrigin, SshParameters};
use std::ffi::OsString;
use std::path::PathBuf;
use std::str::FromStr;
pub const DEFAULT_WINDOW_CLASS: &str = "org.wezfurlong.wezterm";
@@ -161,7 +162,7 @@ pub struct StartCommand {
/// Specify the current working directory for the initially
/// spawned program
#[arg(long = "cwd", value_parser, value_hint=ValueHint::DirPath)]
pub cwd: Option<OsString>,
pub cwd: Option<PathBuf>,
/// Dummy argument that consumes "-e" and does nothing.
/// This is meant as a compatibility layer for supporting the
+7 -1
View File
@@ -15,7 +15,9 @@ use mux::ssh::RemoteSshDomain;
use mux::Mux;
use portable_pty::cmdbuilder::CommandBuilder;
use promise::spawn::block_on;
use std::borrow::Cow;
use std::collections::HashMap;
use std::env::current_dir;
use std::ffi::OsString;
use std::path::PathBuf;
use std::rc::Rc;
@@ -693,7 +695,11 @@ fn run_terminal_gui(opts: StartCommand) -> anyhow::Result<()> {
config.default_cwd.as_ref(),
)?;
if let Some(cwd) = &opts.cwd {
builder.cwd(cwd);
builder.cwd(if cwd.is_relative() {
current_dir()?.join(cwd).into_os_string().into()
} else {
Cow::Borrowed(cwd.as_ref())
});
}
Some(builder)
} else {