Skip to content

Commit 45b5f50

Browse files
committed
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.
1 parent bf81d42 commit 45b5f50

File tree

1 file changed

+3
-3
lines changed
  • src/tools/build-manifest/src

1 file changed

+3
-3
lines changed

src/tools/build-manifest/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ fn main() {
205205
//
206206
// Once the old release process is fully decommissioned, the environment variable, all the
207207
// related code in this tool and ./x.py dist hash-and-sign can be removed.
208-
let legacy = env::var("BUILD_MANIFEST_LEGACY").is_ok();
208+
let legacy = env::var_os("BUILD_MANIFEST_LEGACY").is_some();
209209

210210
let num_threads = if legacy {
211211
// Avoid overloading the old server in legacy mode.
212212
1
213-
} else if let Ok(num) = env::var("BUILD_MANIFEST_NUM_THREADS") {
214-
num.parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
213+
} else if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") {
214+
num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
215215
} else {
216216
num_cpus::get()
217217
};

0 commit comments

Comments
 (0)