Revamp status item handling.
[paraslash.git] / command_util.sh
index 62a406c..a7f1b54 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 
 read_header()
 
 
 read_header()
@@ -26,6 +26,12 @@ read_header()
                AT:)
                        array_type="$value"
                        ;;
                AT:)
                        array_type="$value"
                        ;;
+               SI:)
+                       for i in $value; do
+                               system_includes="$system_includes
+#include <$i.h>"
+                       done
+                       ;;
                IN:)
                        for i in $value; do
                                includes="$includes
                IN:)
                        for i in $value; do
                                includes="$includes
@@ -148,7 +154,7 @@ dump_man()
                        local t_name_txt=$(echo $name_txt | $sed_cmd)
                        echo ".SS \"$t_name_txt\""
                done
                        local t_name_txt=$(echo $name_txt | $sed_cmd)
                        echo ".SS \"$t_name_txt\""
                done
-               echo "$desc_txt"
+               echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g"
                echo
                echo "\\fBUsage: \\fP"
                echo
                echo
                echo "\\fBUsage: \\fP"
                echo
@@ -161,7 +167,7 @@ dump_man()
                echo ".fi"
        fi
        echo
                echo ".fi"
        fi
        echo
-       echo "$help_txt"
+       echo "$help_txt" | sed -e 's/^  //'
        echo
        if test -n "$perms_txt"; then
                echo -n "\\fBpermissions:\\fP "
        echo
        if test -n "$perms_txt"; then
                echo -n "\\fBpermissions:\\fP "
@@ -241,7 +247,7 @@ dump_array_member()
        echo ".description = \"$desc_txt\","
        echo ".usage = \"$usage_txt\","
        echo ".help = "
        echo ".description = \"$desc_txt\","
        echo ".usage = \"$usage_txt\","
        echo ".help = "
-       echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
+       printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
        echo '},'
 }
 
        echo '},'
 }
 
@@ -263,7 +269,7 @@ template_loop()
                perms_txt=$(echo $t_perms | $sed_cmd)
                desc_txt=$(echo $t_desc | $sed_cmd)
                usage_txt=$(echo $t_usage | $sed_cmd)
                perms_txt=$(echo $t_perms | $sed_cmd)
                desc_txt=$(echo $t_desc | $sed_cmd)
                usage_txt=$(echo $t_usage | $sed_cmd)
-               help_txt=$(echo $t_help | $sed_cmd)
+               help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
                prototype=$(echo "$template_prototype" | $sed_cmd)
                $1
        done
                prototype=$(echo "$template_prototype" | $sed_cmd)
                $1
        done
@@ -273,6 +279,7 @@ template_loop()
 com_c_file()
 {
        echo "/** \file $output_file.c $c_file_comment */"
 com_c_file()
 {
        echo "/** \file $output_file.c $c_file_comment */"
+       echo "$system_includes"
        echo "$includes"
        echo "struct $array_type $array_name[] = {"
        while : ; do
        echo "$includes"
        echo "struct $array_type $array_name[] = {"
        while : ; do