]> git.tuebingen.mpg.de Git - gsu.git/blobdiff - subcommand
subcommand: Do not duplicate options to com_prefs().
[gsu.git] / subcommand
index 6011ee68aad6b88103455167ea129008da1ec792..343f248ea45a07411fa61a576532b5566a2bf9b1 100644 (file)
@@ -52,11 +52,13 @@ _gsu_available_commands()
 
 _gsu_print_available_commands()
 {
-       local cmd
+       local cmd cmds
        local -i count=0
 
+       _gsu_available_commands
+       cmds="$result"
        printf 'Available commands:\n'
-       for cmd in $gsu_cmds; do
+       for cmd in $cmds; do
                printf '%s' "$cmd"
                let ++count
                if (($count % 4)); then
@@ -91,6 +93,8 @@ gsu_complete_options()
        done
 }
 
+com_prefs_options='e'
+
 export gsu_prefs_txt="
 Print the current preferences.
 
@@ -105,7 +109,7 @@ com_prefs()
 {
        local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}"
 
-       gsu_getopts "e"
+       gsu_getopts "$com_prefs_options"
        eval "$result"
        (($ret < 0)) && return
        gsu_check_arg_count $# 0 0
@@ -151,7 +155,7 @@ com_prefs()
 
 complete_prefs()
 {
-       gsu_complete_options "e" "$@"
+       gsu_complete_options "$com_prefs_options" "$@"
 }
 
 export gsu_man_txt="
@@ -530,8 +534,7 @@ gsu_get_unnamed_arg_num()
 gsu()
 {
        local i
-       _gsu_available_commands
-       gsu_cmds="$result"
+
        if (($# == 0)); then
                _gsu_usage
                _gsu_print_available_commands