subcommand: Fix some format string issues.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 7 Oct 2017 12:59:46 +0000 (14:59 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 7 Oct 2017 12:59:46 +0000 (14:59 +0200)
One should never use variables in format strings. Found by shellcheck.

subcommand

index 7da8048..34553b8 100644 (file)
@@ -255,13 +255,13 @@ com_prefs()
                        printf "# optional"
                        ;;
                esac
-               printf " $option_type: $description"
+               printf "%s: %s" "$option_type" "$description"
                if [[ "$required" != "yes" && "$required" != "true" ]]; then
-                       printf " [$default_value]"
+                       printf " [%s]" "$default_value"
                fi
                echo
                [[ -n "$help_text" ]] && sed -e '/^[    ]*$/d; s/^[     ]*/#    /g' <<< "$help_text"
-               printf "$name=$val"
+               printf "%s=%s" "$name" "$val"
                [[ "$val" == "$default_value" ]] && printf " # default"
                echo
        done
@@ -360,11 +360,11 @@ com_help()
                gsu_short_msg "### $gsu_name -- $gsu_banner_txt ###"
                _gsu_usage 2>&1
                {
-                       printf "com_help()\n$_gsu_help_txt" | head -n 4; echo "--"
-                       printf "com_man()\n$_gsu_man_txt" | head -n 4; echo "--"
-                       printf "com_prefs()\n$_gsu_prefs_txt" | head -n 4; echo "--"
-                       printf "com_complete()\n$_gsu_complete_txt" | head -n 4; echo "--"
-                       grep -EA 2 "$ere" $0
+                       printf "com_help()\n%s" "$_gsu_help_txt" | head -n 4; echo "--"
+                       printf "com_man()\n%s" "$_gsu_man_txt" | head -n 4; echo "--"
+                       printf "com_prefs()\n%s" "$_gsu_prefs_txt" | head -n 4; echo "--"
+                       printf "com_complete()\n%s" "$_gsu_complete_txt" | head -n 4; echo "--"
+                       grep -EA 2 "$ere" "$0"
                } | grep -v -- '--' \
                        | sed -En "/$ere/"'!d
                                # remove everything but the command name