Skip to contentSkip to conversation

testsuite: fix 'format help' / validate number of arguments

PATCH New Luc Van Oostenryck 1 participant 1 message Jun 22, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testsuite: fix 'format help' / validate number of arguments

The subcommand 'format help' is broken because the of the way arguments are parsed without validating the number of arguments.

Fix this by parsing all arguments (even if there is only one) and validate the number of arguments at the end of the loop.

---
 validation/test-suite | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
validation/test-suite +6 -1
index a22f70135fb3..d351ebf3c428 100755
@@ -474,7 +474,7 @@ do_format()
 	linear=0
 	fail=0
 
-	while [ $# -gt 1 ] ; do
+	while [ $# -gt 0 ] ; do
 		case "$1" in
 		-a)
 			append=1 ;;
@@ -493,6 +493,11 @@ do_format()
 		continue
 	done
 
+	if [ $# -lt 1 -o $# -gt 3 ]; then
+		do_format_help
+		return 0
+	fi
+
 	arg_file "$1" || return 1
 
 	file="$1"
Signature · 1 line
2.27.0