Allow to pass the command to execute via "-e"
Right now wezterm already allows to pass a cmdline to execute (instead of the shell) by calling "wezterm start" with trailing arguments, e.g. wezterm start -- bash However, most other terminals implement this via a "-e" option. This seems to be adopted widely in the wild, such that some third-party frameworks just blindly expect the user's terminal to use the "-e" option for this. One such notable framework is kio from KDE Plasma, that calls the user's terminal in that way when launching a desktop file that uses Terminal=true. [1] To solve this problem, we add a compatibility layer by adding a dummy "-e" option. This will then consume the "-e" leaving the remaining arguments as trailing arguments, which will later be consumed by our existing implementation in the "prog" option. Given that clap does not really support multiple arguments writing to the same destination [2], this seems like the most sane implementation, even if it is a hack. It seems to work reliable, even for edge cases where we pass wezterm options as trailing arguments, e.g. the following will just work and do the expected outcome (and will **not** parse "--position" as a wezterm argument): wezterm start -e echo --position 10,10 Fixes #2622 [1] https://bugs.kde.org/show_bug.cgi?id=459616 [2] https://github.com/clap-rs/clap/issues/3146
This commit is contained in:
1 parent
40e08fafe2
commit
0d4cd8a1e0
2 files changed
+13
No files matched your search
@@ -163,6 +163,18 @@ pub struct StartCommand {
|
||||
#[arg(long = "cwd", value_parser, value_hint=ValueHint::DirPath)]
|
||||
pub cwd: Option<OsString>,
|
||||
|
||||
/// Dummy argument that consumes "-e" and does nothing.
|
||||
/// This is meant as a compatibility layer for supporting the
|
||||
/// widely adopted standard of passing the command to execute
|
||||
/// to the terminal via a "-e" option.
|
||||
/// This works because we then treat the remaining cmdline as
|
||||
/// trailing options, that will automatically be parsed via the
|
||||
/// existing "prog" option.
|
||||
/// This option exists only as a fallback. It is recommended to pass
|
||||
/// the command as a normal trailing command instead if possible.
|
||||
#[arg(short = 'e', hide = true)]
|
||||
pub _cmd: bool,
|
||||
|
||||
/// Override the default windowing system class.
|
||||
/// The default is "org.wezfurlong.wezterm".
|
||||
/// Under X11 and Windows this changes the window class.
|
||||
|
||||
@@ -143,6 +143,7 @@ async fn async_run_ssh(opts: SshCommand) -> anyhow::Result<()> {
|
||||
position: opts.position,
|
||||
workspace: None,
|
||||
prog: opts.prog.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let cmd = if !opts.prog.is_empty() {
|
||||
|
||||
Reference in new issue
Block a user