diff options
author | Melody Horn <melody@boringcactus.com> | 2024-12-18 23:09:38 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-12-18 23:09:38 -0700 |
commit | ad2d35f273403469e64ca8ccc3d2ba594609fa30 (patch) | |
tree | 70fe414228cf3e666b695f19c044cd0ea2d3294e /src | |
parent | fc6f64a92e00bf97dcb5b6ea4e7a4a6eca190f03 (diff) | |
download | makers-ad2d35f273403469e64ca8ccc3d2ba594609fa30.tar.gz makers-ad2d35f273403469e64ca8ccc3d2ba594609fa30.zip |
quote things in generated MAKEFLAGS to avoid suffering
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 13 |
1 files changed, 8 insertions, 5 deletions
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'"); } } |