From cbded3e193ba7acc4611e9b8612bbc98608e7800 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 12 Oct 2020 19:34:01 +0200 Subject: [PATCH] build-manifest: use var_os instead of var to check if vars exist This will prevent the tool mistakenly ignoring the variables if they happen to contain non-utf8 data. --- src/tools/build-manifest/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 6fda9f4e59f..1515f46e03a 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -205,13 +205,13 @@ fn main() { // // Once the old release process is fully decommissioned, the environment variable, all the // related code in this tool and ./x.py dist hash-and-sign can be removed. - let legacy = env::var("BUILD_MANIFEST_LEGACY").is_ok(); + let legacy = env::var_os("BUILD_MANIFEST_LEGACY").is_some(); let num_threads = if legacy { // Avoid overloading the old server in legacy mode. 1 - } else if let Ok(num) = env::var("BUILD_MANIFEST_NUM_THREADS") { - num.parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS") + } else if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") { + num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS") } else { num_cpus::get() };