mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 13:16:39 +03:00
Always start a new process on "wezterm -e $CMD"
This is done for compatibility, as many tools assume that running a command with "$TERMINAL -e $COMMAND" blocks until the command is finished. For example some tools delete a needed file after the command returns. But since we always return immediately (in case --always-new-process is not provided and if another wezterm instance is already running), this would mean that the file is deleted before the command could do anything. Fixes #4523
This commit is contained in:
parent
767e72a17b
commit
191d28113e
@ -5,7 +5,7 @@ Usage: wezterm [OPTIONS] [COMMAND]
|
||||
|
||||
Commands:
|
||||
start Start the GUI, optionally running an alternative
|
||||
program [aliases: -e]
|
||||
program
|
||||
ssh Establish an ssh session
|
||||
serial Open a serial port
|
||||
connect Connect to wezterm multiplexer
|
||||
|
@ -26,7 +26,6 @@ pub fn name_equals_value(arg: &str) -> Result<(String, String), String> {
|
||||
|
||||
#[derive(Debug, Parser, Default, Clone)]
|
||||
#[command(trailing_var_arg = true)]
|
||||
#[command(visible_short_flag_alias = 'e')]
|
||||
pub struct StartCommand {
|
||||
/// If true, do not connect to domains marked as connect_automatically
|
||||
/// in your wezterm configuration file.
|
||||
|
@ -110,6 +110,9 @@ enum SubCommand {
|
||||
)]
|
||||
Start(StartCommand),
|
||||
|
||||
#[command(short_flag_alias = 'e', hide = true)]
|
||||
BlockingStart(StartCommand),
|
||||
|
||||
#[command(name = "ssh", about = "Establish an ssh session")]
|
||||
Ssh(SshCommand),
|
||||
|
||||
@ -1195,6 +1198,16 @@ fn run() -> anyhow::Result<()> {
|
||||
let config = config::configuration();
|
||||
|
||||
let sub = match opts.cmd.as_ref().cloned() {
|
||||
Some(SubCommand::BlockingStart(start)) => {
|
||||
// Act as if the normal start subcommand was used,
|
||||
// except that we always start a new instance.
|
||||
// This is needed for compatibility, because many tools assume
|
||||
// that "$TERMINAL -e $COMMAND" blocks until the command finished.
|
||||
SubCommand::Start(StartCommand {
|
||||
always_new_process: true,
|
||||
..start
|
||||
})
|
||||
}
|
||||
Some(sub) => sub,
|
||||
None => {
|
||||
// Need to fake an argv0
|
||||
@ -1218,6 +1231,7 @@ fn run() -> anyhow::Result<()> {
|
||||
wezterm_blob_leases::clear_storage();
|
||||
res
|
||||
}
|
||||
SubCommand::BlockingStart(_) => unreachable!(),
|
||||
SubCommand::Ssh(ssh) => run_ssh(ssh),
|
||||
SubCommand::Serial(serial) => run_serial(config, serial),
|
||||
SubCommand::Connect(connect) => run_terminal_gui(
|
||||
|
Loading…
Reference in New Issue
Block a user