Fix getopts with blank argument's value

There's no reason in that loop where we're looking for values of an option to have a blank cell in the array of arguments. Unless for an option with a missing value.
In that case, it's better to ignore this condition and store a blank value in the variable.
Otherwise, in case of missing value for an option, with this condition, we enter in an infinite loop, because the shift will stay at 0.
This commit is contained in:
Maniack Crudelis 2019-01-04 18:44:40 +01:00
parent 1a4e661e4e
commit 50f3291ea7

View file

@ -136,7 +136,7 @@ ynh_handle_getopts_args () {
for i in `seq 0 $(( ${#all_args[@]} - 1 ))` for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
do do
# If this argument is an option, end here. # If this argument is an option, end here.
if [ "${all_args[$i]:0:1}" == "-" ] || [ -z "${all_args[$i]}" ] if [ "${all_args[$i]:0:1}" == "-" ]
then then
# Ignore the first value of the array, which is the option itself # Ignore the first value of the array, which is the option itself
if [ "$i" -ne 0 ]; then if [ "$i" -ne 0 ]; then