forked from meli/meli
1
Fork 0

chore: Improve error message when `m4` executable is missing.

duesee/experiment/use_imap_codec
Damian Poddebniak 2023-05-17 11:16:10 +02:00 committed by duesee
parent 682ea5547e
commit f63f6445ad
1 changed files with 10 additions and 2 deletions

View File

@ -348,11 +348,19 @@ changequote(`"', `"')dnl
let mut file = std::fs::File::open(&p)?;
file.read_to_string(&mut contents)?;
let mut handle = Command::new("m4")
let mut handle = match Command::new("m4")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?;
.spawn()
{
Ok(handle) => handle,
Err(error) => match error.kind() {
io::ErrorKind::NotFound => return Err("`m4` executable not found. Please install.".into()),
_ => return Err(error.into()),
}
};
let mut stdin = handle.stdin.take().unwrap();
stdin.write_all(M4_PREAMBLE.as_bytes())?;
stdin.write_all(contents.as_bytes())?;