diff options
author | Profpatsch <mail@profpatsch.de> | 2022-01-05 18:35:14 +0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2022-01-07 15:01:34 +0100 |
commit | e0c3c5cc2996a1a80bff4987d79de0987588c2ea (patch) | |
tree | d3d83ceab902edca3afde1dfc8fc4c793cd0f1e1 | |
parent | 3e46b784064c18ff2aa2cc41745fc3c6289ad94a (diff) |
pkgs/profpatsch/e: add debug output
-rw-r--r-- | pkgs/profpatsch/execline/run-cmd-line-block.rs | 18 |
1 files changed, 15 insertions, 3 deletions
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<OsString> = 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() + } }) } |