From f50bfeea92fee4b554d43a883f007300af7f475f Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 28 Aug 2024 18:05:56 -0600 Subject: [PATCH] fop(1): fixes panic on no arguments --- src/fop.rs | 2 ++ tests/bonsai/fop.mk | 1 + 2 files changed, 3 insertions(+) diff --git a/src/fop.rs b/src/fop.rs index b6da510..261aba5 100644 --- a/src/fop.rs +++ b/src/fop.rs @@ -61,6 +61,8 @@ fn main() -> ExitCode { } } + if argv.len() == 1 { return ExitCode::from(usage(&argv[0])); } + while let Some(opt) = argv.getopt("d:") { match opt.opt() { Ok("d") => { diff --git a/tests/bonsai/fop.mk b/tests/bonsai/fop.mk index b538031..230e1c1 100755 --- a/tests/bonsai/fop.mk +++ b/tests/bonsai/fop.mk @@ -24,6 +24,7 @@ fop_fail: $(BIN)/fop ! printf 'test\n' | $(BIN)/fop 1 cat ! printf 'test\n' | $(BIN)/fop 'test' cat ! printf 'test\n' | $(BIN)/fop -d'test' cat + ! $(BIN)/fop .PHONY: fop_functionality fop_functionality: $(BIN)/fop