Merge pull request #948 from YunoHost/fix_getopts

Fix getopts with empty parameters
This commit is contained in:
Alexandre Aubin 2020-04-22 03:45:41 +02:00 committed by GitHub
commit b1b1e8f867
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -147,6 +147,9 @@ ynh_handle_getopts_args () {
break break
fi fi
else else
# Ignore empty parameters
if [ -n "${all_args[$i]}" ]
then
# Else, add this value to this option # Else, add this value to this option
# Each value will be separated by ';' # Each value will be separated by ';'
if [ -n "${!option_var}" ] if [ -n "${!option_var}" ]
@ -166,6 +169,7 @@ ynh_handle_getopts_args () {
# So... Stop fucking arguing each time that eval is evil... Go find an other working solution if you can find one! # So... Stop fucking arguing each time that eval is evil... Go find an other working solution if you can find one!
eval ${option_var}+='"${all_args[$i]}"' eval ${option_var}+='"${all_args[$i]}"'
fi
shift_value=$(( shift_value + 1 )) shift_value=$(( shift_value + 1 ))
fi fi
done done