From e0c3c5cc2996a1a80bff4987d79de0987588c2ea Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Wed, 5 Jan 2022 18:35:14 +0100 Subject: pkgs/profpatsch/e: add debug output --- pkgs/profpatsch/execline/run-cmd-line-block.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'pkgs/profpatsch/execline') diff --git a/pkgs/profpatsch/execline/run-cmd-line-block.rs b/pkgs/profpatsch/execline/run-cmd-line-block.rs index 324ce858..e0bc940b 100644 --- a/pkgs/profpatsch/execline/run-cmd-line-block.rs +++ b/pkgs/profpatsch/execline/run-cmd-line-block.rs @@ -4,6 +4,9 @@ use std::os::unix::process::CommandExt; fn main() -> std::io::Result<()> { let args = std::env::args_os(); + let is_debug = std::env::var_os("DEBUG_E").is_some(); + let dbg = |msg| if is_debug { eprintln!("{}", msg); } else {}; + let mut cmd : Vec = vec![]; let mut depth = 0; for arg in args.skip(1) { @@ -18,11 +21,20 @@ fn main() -> std::io::Result<()> { } Err(match cmd.len() { - 0 => std::process::exit(0), - 1 => Command::new(&cmd[0]).exec(), - _ => Command::new(&cmd[0]) + 0 => { + dbg(format!("e: Exiting, no commands given")); + std::process::exit(0) + }, + 1 => { + dbg(format!("e: Executing {:?}", cmd)); + Command::new(&cmd[0]).exec() + }, + _ => { + dbg(format!("e: Executing {:?}", cmd)); + Command::new(&cmd[0]) .args(&cmd[1..]) .exec() + } }) } -- cgit 1.4.1