From 6945867f860f5a42390f36dd88dfabd6b7e92a65 Mon Sep 17 00:00:00 2001 From: Kayou Date: Wed, 16 Sep 2020 13:23:10 +0200 Subject: [PATCH] detect wrong arguments --- data/helpers.d/getopts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/helpers.d/getopts b/data/helpers.d/getopts index a4bbe20e6..8d9e55826 100644 --- a/data/helpers.d/getopts +++ b/data/helpers.d/getopts @@ -130,6 +130,12 @@ ynh_handle_getopts_args () { then # Remove the option and the space, so keep only the value itself. all_args[0]="${all_args[0]#-${parameter} }" + + # At this point, if all_args[0] start with "-", then the argument is not well formed + if [ "${all_args[0]:0:1}" == "-" ] + then + ynh_die --message="Argument \"${all_args[0]}\" not valid! Did you use a single \"-\" instead of two?" + fi # Reduce the value of shift, because the option has been removed manually shift_value=$(( shift_value - 1 )) fi