X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=funcs%2Fgsu;h=b409bc50bc75d50969d60a800c0710358c34c2d9;hb=5102a3ed6cf2d4b1addecf52495faafc04107cc5;hp=75e569cb0a00789badb00735bf3a36f8391ce6db;hpb=b3e4039f76f3af4dc2c11642e9edd8309161951c;p=gsu.git diff --git a/funcs/gsu b/funcs/gsu index 75e569c..b409bc5 100644 --- a/funcs/gsu +++ b/funcs/gsu @@ -45,17 +45,25 @@ gsu_is_a_number() } export -f gsu_is_a_number +# Check number of arguments. +# # Usage: gsu_check_arg_count [] # -# If only ist given, then must equal . -# Otherwise, .. is treated as a range and it is checked -# that lies between and inclusively. +# Check that is between and inclusively. +# If only ist given, num2 is assumed to be infinity. +# +# Examples: +# 0 0 no argument allowed +# 1 1 exactly one argument required +# 0 2 at most two arguments admissible +# 2 at least two arguments reqired +# gsu_check_arg_count() { ret=-$E_GSU_BAD_ARG_COUNT if [[ $# -eq 2 ]]; then # only num1 is given - result="exactly $2 args needed, $1 given" - [[ $1 -ne $2 ]] && return + result="at least $2 args required, $1 given" + [[ $1 -lt $2 ]] && return ret=$GSU_SUCCESS return fi @@ -357,7 +365,7 @@ _gsu_check_options() return esac - eval ${gsu_config_var_prefix}_$name="\"${val:=$default_value}\"" + eval ${gsu_config_var_prefix}_$name='"'${val:=$default_value}'"' # Check option type. ATM, only num and string are supported # Other types may be added without breaking compatibility case "$option_type" in