]> git.tuebingen.mpg.de Git - gsu.git/blobdiff - misc/gsu/subcommand
gsu: Avoid parameter expansion on unset variables.
[gsu.git] / misc / gsu / subcommand
index a688ed5855c60c47e099b723bf8b060487a7669a..e1130efce334f19964155e751c580c66026c7eba 100644 (file)
@@ -42,7 +42,7 @@ _gsu_available_commands()
 
 _gsu_print_available_commands()
 {(
 
 _gsu_print_available_commands()
 {(
-       local i count
+       local i count=0
        gsu_short_msg "Available commands:"
        for i in $gsu_cmds; do
                printf "$i"
        gsu_short_msg "Available commands:"
        for i in $gsu_cmds; do
                printf "$i"
@@ -216,7 +216,7 @@ _com_help()
        _gsu_get_command_regex
        ere="$result"
 
        _gsu_get_command_regex
        ere="$result"
 
-       if test -z "$1"; then
+       if (($# == 0)); then
                _gsu_banner_msg 2>&1
                _gsu_usage 2>&1
                {
                _gsu_banner_msg 2>&1
                _gsu_usage 2>&1
                {
@@ -355,11 +355,11 @@ gsu_getopts()
        for ((i=0; i < ${#1}; i++)); do
                c1=${1:$i:1}
                c2=${1:$(($i + 1)):1}
        for ((i=0; i < ${#1}; i++)); do
                c1=${1:$i:1}
                c2=${1:$(($i + 1)):1}
-               result+=" o_$c1"
+               result+=" o_$c1="
                if [[ "$c2" = ":" ]]; then
                        let i++
                else
                if [[ "$c2" = ":" ]]; then
                        let i++
                else
-                       result+="=false"
+                       result+="false"
                fi
        done
        result+="
                fi
        done
        result+="