about summary refs log tree commit diff
path: root/users/Profpatsch
diff options
context:
space:
mode:
Diffstat (limited to 'users/Profpatsch')
-rw-r--r--users/Profpatsch/execline/exec_helpers.rs9
-rw-r--r--users/Profpatsch/read-http.rs2
2 files changed, 11 insertions, 0 deletions
diff --git a/users/Profpatsch/execline/exec_helpers.rs b/users/Profpatsch/execline/exec_helpers.rs
index b0b0984911a5..bc4650fbad9a 100644
--- a/users/Profpatsch/execline/exec_helpers.rs
+++ b/users/Profpatsch/execline/exec_helpers.rs
@@ -2,6 +2,15 @@ use std::os::unix::process::CommandExt;
 use std::ffi::OsStr;
 use std::os::unix::ffi::{OsStringExt, OsStrExt};
 
+pub fn no_args(current_prog_name: &str) -> () {
+    let mut args = std::env::args_os();
+    // remove argv[0]
+    let _ = args.nth(0);
+    if args.len() > 0 {
+        die_user_error(current_prog_name, format!("Expected no arguments, got {:?}", args.collect::<Vec<_>>()))
+    }
+}
+
 pub fn args_for_exec(current_prog_name: &str, no_of_positional_args: usize) -> (Vec<Vec<u8>>, Vec<Vec<u8>>) {
     let mut args = std::env::args_os();
     // remove argv[0]
diff --git a/users/Profpatsch/read-http.rs b/users/Profpatsch/read-http.rs
index afbfbfdb6714..50ff663b994a 100644
--- a/users/Profpatsch/read-http.rs
+++ b/users/Profpatsch/read-http.rs
@@ -22,6 +22,8 @@ enum What {
 // The keys are text, but can be lists of text iff headers appear multiple times, so beware.
 fn main() -> std::io::Result<()> {
 
+    exec_helpers::no_args("read-http");
+
     let args = dec::RecordDot {
         field: "what",
         inner: dec::OneOf {