fix: honor environment variables and cwd unconditionally for SpawnCommand (#6850)
* fix: honor environment variables and cwd unconditionally for SpawnCommand The SpawnCommand specifies information about a new command to be spawned. If the args field is omitted, the default program for the target domain is spawned. However, this also causes other fields like environment variables and cwd to be wiped out. The command builder now behaves consistently for all fields, whether the args field is set or omitted. Co-authored-by: Wez Furlong <wez@wezfurlong.org>
This commit is contained in:
1 parent
7f52f05580
commit
0bb382bf54
1 file changed
+19
-10
+19
-10
@@ -68,17 +68,26 @@ pub async fn spawn_command_internal(
|
||||
None
|
||||
};
|
||||
|
||||
let cmd_builder = if let Some(args) = spawn.args {
|
||||
let mut builder = CommandBuilder::from_argv(args.iter().map(Into::into).collect());
|
||||
for (k, v) in spawn.set_environment_variables.iter() {
|
||||
builder.env(k, v);
|
||||
let cmd_builder = match (
|
||||
spawn.args.as_ref(),
|
||||
spawn.cwd.as_ref(),
|
||||
spawn.set_environment_variables.is_empty(),
|
||||
) {
|
||||
(None, None, true) => None,
|
||||
_ => {
|
||||
let mut builder = spawn
|
||||
.args
|
||||
.as_ref()
|
||||
.map(|args| CommandBuilder::from_argv(args.iter().map(Into::into).collect()))
|
||||
.unwrap_or_else(CommandBuilder::new_default_prog);
|
||||
for (k, v) in spawn.set_environment_variables.iter() {
|
||||
builder.env(k, v);
|
||||
}
|
||||
if let Some(cwd) = &spawn.cwd {
|
||||
builder.cwd(cwd);
|
||||
}
|
||||
Some(builder)
|
||||
}
|
||||
if let Some(cwd) = spawn.cwd {
|
||||
builder.cwd(cwd);
|
||||
}
|
||||
Some(builder)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let workspace = mux.active_workspace().clone();
|
||||
|
||||
Reference in new issue
Block a user