gsu: com_prefs -e fixes.
authorAndre Noll <maan@systemlinux.org>
Sun, 10 Oct 2010 09:12:51 +0000 (11:12 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 29 Aug 2014 19:36:08 +0000 (21:36 +0200)
Create the subdirectory for the config file if it does not exist, and fix the
return value for the editor command.

funcs/gsu

index b873ad9..f536717 100644 (file)
--- a/funcs/gsu
+++ b/funcs/gsu
@@ -14,6 +14,7 @@ E_GSU_BAD_BOOL                        bad value for boolian option
 E_GSU_BAD_OPTION_TYPE          invalid option type
 E_GSU_BAD_ARG_COUNT            invalid number of arguments
 E_GSU_EDITOR                   failed to execute editor
+E_GSU_MKDIR                    failed to create directory
 $gsu_errors
 "
        local a b i=0
@@ -179,9 +180,14 @@ _com_prefs()
        local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}"
 
        if [[ "$1" = "-e" ]]; then
+               ret=-$E_GSU_MKDIR
+               result="${conf%/*}"
+               mkdir -p "$result"
+               [[ $? -ne 0 ]] && return
                ret=-$E_GSU_EDITOR
                result="${EDITOR:-vi}"
                "$result" "$conf"
+               [[ $? -ne 0 ]] && return
                ret=$GSU_SUCCESS
                return
        fi