]> 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 ff77daeac5e0c83a1cdeb482250a3feb301e1af4..09330f355cc5b16d8cb0288760f3c620f92c65ef 100644 (file)
@@ -4,7 +4,7 @@
 # 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]}"
@@ -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
@@ -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
@@ -81,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