From 51bef36a608d3447236c069863481fad763ceb33 Mon Sep 17 00:00:00 2001 From: Shinyzenith Date: Tue, 6 Sep 2022 09:03:06 +0530 Subject: [PATCH] [build.rs] Fix scdoc parent stdio inheritance Signed-off-by: Shinyzenith --- build.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/build.rs b/build.rs index 3925a55d..283e42e7 100644 --- a/build.rs +++ b/build.rs @@ -2,19 +2,19 @@ use std::{ fs::{read_dir, File, OpenOptions}, io::ErrorKind, path::Path, - process::exit, - process::{Command, Stdio}, + process::{exit, Command, Stdio}, }; fn main() { - // Check if scdoc command exists - match Command::new("scdoc").spawn() { - Err(e) => { - if let ErrorKind::NotFound = e.kind() { - exit(0); - } + if let Err(e) = Command::new("scdoc") + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .spawn() + { + if let ErrorKind::NotFound = e.kind() { + exit(0); } - _ => {} } let mut man_pages: Vec<(String, String)> = Vec::new(); @@ -25,17 +25,18 @@ fn main() { } if let Some(file_name) = path.path().to_str() { + if path.path().extension().unwrap().to_str().unwrap() == "gz" { + continue; + } + let man_page_name = file_name.replace(".scd", ".gz"); man_pages.push((file_name.to_string(), man_page_name)); } } for man_page in man_pages { - let output = OpenOptions::new() - .write(true) - .create(true) - .open(Path::new(&man_page.1)) - .unwrap(); + let output = + OpenOptions::new().write(true).create(true).open(Path::new(&man_page.1)).unwrap(); _ = Command::new("scdoc") .stdin(Stdio::from(File::open(man_page.0).unwrap())) .stdout(output)