mirror of
https://github.com/lotabout/skim.git
synced 2026-09-10 07:16:23 -04:00
fix(windows): raw_arg to avoid escape issue (#1061)
* fix(windows): raw_arg to avoid escape issue * chore: tweaks --------- Co-authored-by: Loric ANDRE <loric.andre@pm.me>
This commit is contained in:
parent
bf63404ad5
commit
cf49f60d96
17
src/lib.rs
17
src/lib.rs
|
|
@ -20,10 +20,12 @@
|
|||
//! ).unwrap();
|
||||
//! ```
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![warn(clippy::pedantic)]
|
||||
#![warn(clippy::incompatible_msrv)]
|
||||
#![allow(clippy::default_trait_access, clippy::struct_excessive_bools)]
|
||||
#![warn(clippy::pedantic, missing_docs, clippy::incompatible_msrv)]
|
||||
#![allow(
|
||||
clippy::default_trait_access,
|
||||
clippy::struct_excessive_bools,
|
||||
clippy::collapsible_match
|
||||
)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
|
@ -91,8 +93,13 @@ fn shell_cmd(cmd: &str) -> Command {
|
|||
}
|
||||
#[cfg(windows)]
|
||||
fn shell_cmd(cmd: &str) -> Command {
|
||||
use std::os::windows::process::CommandExt as _;
|
||||
// `cmd.exe` does not parse its command line using MSVC rules, so the default
|
||||
// `Command::arg` escaping (quoting/backslash-escaping) corrupts shell
|
||||
// metacharacters like `|`, `&`, `>` and embedded quotes. Pass the command
|
||||
// string verbatim via `raw_arg` so cmd.exe sees exactly what the user wrote.
|
||||
let mut c = Command::new("cmd");
|
||||
c.arg("/c").arg(cmd);
|
||||
c.arg("/c").raw_arg(cmd);
|
||||
c
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ fn middle_coord(size: Size, var: &str) -> Size {
|
|||
Size::Percent(p) => Size::Percent(100u16.saturating_sub(p) / 2),
|
||||
Size::Fixed(cells) => Size::Fixed(
|
||||
std::env::var(var)
|
||||
.map(|s| s.parse().unwrap_or(80))
|
||||
.unwrap_or(80u16)
|
||||
.map_or(80u16, |s| s.parse().unwrap_or(80))
|
||||
.saturating_sub(cells)
|
||||
/ 2,
|
||||
),
|
||||
|
|
@ -32,8 +31,7 @@ fn align_end_coord(size: Size, var: &str) -> Size {
|
|||
Size::Percent(p) => Size::Percent(100 - p),
|
||||
Size::Fixed(cols) => Size::Fixed(
|
||||
std::env::var(var)
|
||||
.map(|s| s.parse().unwrap_or(80))
|
||||
.unwrap_or(80u16)
|
||||
.map_or(80u16, |s| s.parse().unwrap_or(80))
|
||||
.saturating_sub(cols),
|
||||
),
|
||||
Size::Neg(cells) => Size::Fixed(cells),
|
||||
|
|
|
|||
|
|
@ -93,6 +93,6 @@ impl Display for dyn SkimItem {
|
|||
}
|
||||
impl Debug for dyn SkimItem {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("SkimItem {{ text: {} }}", self.text(),))
|
||||
f.write_fmt(format_args!("SkimItem {{ text: {} }}", self.text()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue