aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-12-18 23:09:38 -0700
committerMelody Horn <melody@boringcactus.com>2024-12-18 23:09:38 -0700
commitad2d35f273403469e64ca8ccc3d2ba594609fa30 (patch)
tree70fe414228cf3e666b695f19c044cd0ea2d3294e
parentfc6f64a92e00bf97dcb5b6ea4e7a4a6eca190f03 (diff)
downloadmakers-ad2d35f273403469e64ca8ccc3d2ba594609fa30.tar.gz
makers-ad2d35f273403469e64ca8ccc3d2ba594609fa30.zip
quote things in generated MAKEFLAGS to avoid suffering
-rw-r--r--Cargo.lock3
-rw-r--r--Cargo.toml1
-rw-r--r--src/args.rs13
3 files changed, 11 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 46581a3..e9cb31b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "addr2line"
@@ -350,6 +350,7 @@ dependencies = [
"log",
"nom",
"regex",
+ "shlex",
"tempfile",
]
diff --git a/Cargo.toml b/Cargo.toml
index 450b2f0..4677d37 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,6 +25,7 @@ lazy_static = "1.5.0"
log = "0.4.22"
nom = "7.1.3"
regex = "1.11.0"
+shlex = "1.3.0"
[dev-dependencies]
tempfile = "3.13.0"
diff --git a/src/args.rs b/src/args.rs
index 57ac84c..8489c2d 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -173,7 +173,10 @@ impl Args {
} else {
env_makeflags
};
- let env_makeflags = env_makeflags.split_whitespace().map(OsString::from);
+ let env_makeflags = shlex::split(&env_makeflags)
+ .expect("Bad args?")
+ .into_iter()
+ .map(OsString::from);
// per the structopt docs, the first argument will be used as the binary name,
// so we need to make sure it goes in before MAKEFLAGS
let arg_0 = args.next().unwrap_or_else(|| env!("CARGO_PKG_NAME").into());
@@ -246,9 +249,9 @@ impl Args {
let macros = self
.targets_or_macros
.iter()
- .map(|x| x.as_ref())
- .filter(|x: &&str| x.contains('='))
- .collect::<Vec<&str>>()
+ .map(|x| shlex::try_quote(x).expect("Bad quoting?"))
+ .filter(|x| x.contains('='))
+ .collect::<Vec<_>>()
.join(" ");
let mut result = String::new();
@@ -557,6 +560,6 @@ mod test {
no_print_directory: true,
targets_or_macros: vec!["V=1".into()],
};
- assert_eq!(args.makeflags(), "--no-print-directory V=1");
+ assert_eq!(args.makeflags(), "--no-print-directory 'V=1'");
}
}