]> git.tuebingen.mpg.de Git - gsu.git/blobdiff - misc/gsu/config
gsu: Don't fail if HOME is unset.
[gsu.git] / misc / gsu / config
index df96af2d5e7019c70865e9f371f6511282b4d193..09330f355cc5b16d8cb0288760f3c620f92c65ef 100644 (file)
@@ -4,11 +4,11 @@
 # 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
 
@@ -21,10 +21,8 @@ gsu_check_options()
 
                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
@@ -33,7 +31,7 @@ gsu_check_options()
 
                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
@@ -51,7 +49,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
@@ -69,7 +67,6 @@ gsu_check_options()
        done
        ret=$GSU_SUCCESS
 }
-export -f gsu_check_options
 
 # Call gsu_check_options(), die on errors.
 gsu_check_options_or_die()
@@ -82,7 +79,7 @@ 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