about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2020-10-12 19:34:01 +0200
committerPietro Albini <pietro@pietroalbini.org>2020-10-12 19:53:29 +0200
commitcbded3e193ba7acc4611e9b8612bbc98608e7800 (patch)
tree56ef1015d5ff96fd88c19b77d87e733d77c6543c
parentf3d07b36ed7609a7826200479d8d472d36f0a995 (diff)
downloadrust-cbded3e193ba7acc4611e9b8612bbc98608e7800.tar.gz
rust-cbded3e193ba7acc4611e9b8612bbc98608e7800.zip
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.
-rw-r--r--src/tools/build-manifest/src/main.rs6
1 files 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()
     };