From 6011f6c11aa4f09933219d22bb9d28a3a9b93096 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 11 Aug 2022 21:47:38 +0900 Subject: [PATCH] include/opt: Emit an error if a required parameter is missing When an option expecting a parameter is not passed one, `opt_parse()` does not fail because of an incorrect comparison. This commit fixes the comparison so that `opt_parse()` fails and prints an error message when a required parameter is missing. --- include/opt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/opt.sh b/include/opt.sh index ceebc5e..5ed8d94 100644 --- a/include/opt.sh +++ b/include/opt.sh @@ -180,7 +180,7 @@ opt_parse() { if (( flags & __opt_flag_has_value )); then ((i++)) - if (( i > ${#argv[@]} )); then + if (( i >= ${#argv[@]} )); then log_error "Missing argument after $param" return 1 fi -- 2.47.3