# file.
gsu_check_options()
{
- local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}" val
+ local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val
for ((i=0; i < ${#gsu_options[@]}; i++)); do
eval "${gsu_options[$i]}"
- eval val='"'\$$name'"'
+ eval val='"'\${${name}:-}'"'
eval orig_${gsu_config_var_prefix}_$name='"'${val}'"'
done
eval "${gsu_options[$i]}"
-
# Check name. It must be non-empty and consist of [a-zA-Z_0-9]
# only. Moreover it must not start with [a-zA-Z].
-
ret=-$E_GSU_BAD_CONFIG_VAR
result="name: '$name'"
# bash's =~ works only for 3.2 and newer, so use grep
eval orig_val='"'\$orig_${gsu_config_var_prefix}_$name'"'
if [[ -z "$orig_val" ]]; then
- eval val='"'\$$name'"'
+ eval val='"'\${$name:-}'"'
else
val="$orig_val"
fi
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
done
ret=$GSU_SUCCESS
}
-export -f gsu_check_options
# Call gsu_check_options(), die on errors.
gsu_check_options_or_die()
}
if [[ "$(type -t _gsu_setup)" != "function" ]]; then
- gsu_dir=${gsu_dir:=$HOME/.gsu}
+ gsu_dir=${gsu_dir:=${HOME:-}/.gsu}
. $gsu_dir/common || exit 1
_gsu_setup
fi