Use ShellKind::try_quote whenever we need to quote shell args (#40912)
Using `shlex` unconditionally is dangerous as it assumes the underlying shell is POSIX which is not the case for PowerShell, CMD, or Nushell. Therefore, whenever we want to quote the args we should utilise our helper `util::shell::ShellKind::try_quote` which takes into account which shell is being used to actually exec/spawn the invocation. Release Notes: - N/A --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
This commit is contained in:
co-authored by
Lukas Wirth
parent
18daa9a839
commit
8f4646d6c3
@@ -32,7 +32,7 @@ use ui::{
|
||||
SharedString, Styled, StyledExt, ToggleButton, ToggleState, Toggleable, Tooltip, Window, div,
|
||||
h_flex, relative, rems, v_flex,
|
||||
};
|
||||
use util::{ResultExt, rel_path::RelPath};
|
||||
use util::{ResultExt, rel_path::RelPath, shell::ShellKind};
|
||||
use workspace::{ModalView, Workspace, notifications::DetachAndPromptErr, pane};
|
||||
|
||||
use crate::{attach_modal::AttachModal, debugger_panel::DebugPanel};
|
||||
@@ -837,7 +837,11 @@ impl ConfigureMode {
|
||||
};
|
||||
}
|
||||
let command = self.program.read(cx).text(cx);
|
||||
let mut args = shlex::split(&command).into_iter().flatten().peekable();
|
||||
let mut args = ShellKind::Posix
|
||||
.split(&command)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.peekable();
|
||||
let mut env = FxHashMap::default();
|
||||
while args.peek().is_some_and(|arg| arg.contains('=')) {
|
||||
let arg = args.next().unwrap();
|
||||
@@ -1263,7 +1267,11 @@ impl PickerDelegate for DebugDelegate {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut args = shlex::split(&text).into_iter().flatten().peekable();
|
||||
let mut args = ShellKind::Posix
|
||||
.split(&text)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.peekable();
|
||||
let mut env = HashMap::default();
|
||||
while args.peek().is_some_and(|arg| arg.contains('=')) {
|
||||
let arg = args.next().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user