about summary refs log tree commit diff
path: root/pkgs/profpatsch
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2022-01-05 18:35:14 +0100
committerProfpatsch <mail@profpatsch.de>2022-01-07 15:01:34 +0100
commite0c3c5cc2996a1a80bff4987d79de0987588c2ea (patch)
treed3d83ceab902edca3afde1dfc8fc4c793cd0f1e1 /pkgs/profpatsch
parent3e46b784064c18ff2aa2cc41745fc3c6289ad94a (diff)
pkgs/profpatsch/e: add debug output
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r--pkgs/profpatsch/execline/run-cmd-line-block.rs18
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()
+      }
   })
 }