gsu subcommand: Use gsu_getopts.
authorAndre Noll <maan@systemlinux.org>
Sun, 9 Oct 2011 16:52:03 +0000 (18:52 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 29 Aug 2014 19:39:58 +0000 (21:39 +0200)
This makes the prefs command error out on invalid options
and avoids the expansion of the possibly unset parameter $1.

misc/gsu/subcommand

index 7e706d8..911179e 100644 (file)
@@ -92,7 +92,13 @@ _com_prefs()
 {
        local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}"
 
-       if [[ "$1" = "-e" ]]; then
+       gsu_getopts "e"
+       eval "$result"
+       (($ret < 0)) && return
+       gsu_check_arg_count $# 0 0
+       (($ret < 0)) && return
+
+       if [[ "$o_e" == "true" ]]; then
                ret=-$E_GSU_MKDIR
                result="${conf%/*}"
                mkdir -p "$result"