]> git.tue.mpg.de Git - paraslash.git/commitdiff
command_util: Avoid empty output lines.
authorAndre Noll <maan@systemlinux.org>
Thu, 28 Jun 2012 00:51:28 +0000 (02:51 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 29 Jun 2012 19:36:30 +0000 (21:36 +0200)
Additional empty output lines do not matter for the generated C code or
the function declarations in the header files.  However, a subsequent
commit changes command_util.sh to  generate a preprocessor macro for
the header file, and there we can not afford empty lines unless they
end with a backslash to continue the line.

This patch makes sure that no superfluous newlines are printed in
the output.

command_util.sh

index 563ab1a25ebe80e6e7bd837fa5e613d8ba3e880c..b3b8804c28f4bce50398ebdde5d4c32809a05bc4 100755 (executable)
@@ -198,11 +198,10 @@ make_proto()
        for source_file in $source_files; do
                match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
                if test -n "$match"; then
-                       result="$result $match$CR"
+                       result="$result$match$CR"
                        break
                fi
        done
-       echo
 }
 
 make_array_member()
@@ -229,11 +228,15 @@ make_array_member()
 
 make_completion()
 {
-       result="  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+       local CR='
+'
+       result="  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR"
 }
 
 template_loop()
 {
+       local loop_result=
+
        local t_name="$name_txt"
        local t_perms="$perms_txt"
        local t_desc="$desc_txt"
@@ -251,11 +254,10 @@ template_loop()
                usage_txt=$(echo "$t_usage" | $sed_cmd)
                help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
                prototype=$(echo "$template_prototype" | $sed_cmd)
-               result=
                $1
-               echo "$result"
+               loop_result="$loop_result$result"
        done
-
+       result="$loop_result"
 }
 
 com_c_file()
@@ -273,10 +275,11 @@ com_c_file()
                fi
                if test $template -eq 0; then
                        make_array_member
-                       echo "$result"
+                       printf "%s" "$result"
                        continue
                fi
                template_loop make_array_member
+               printf "%s" "$result"
        done
        echo '{.name = NULL}};'
 }
@@ -294,10 +297,11 @@ com_header()
                fi
                if test $template -eq 0; then
                        make_proto
-                       echo "$result"
+                       printf "%s" "$result"
                        continue
                fi
                template_loop make_proto
+               printf "%s" "$result"
        done
 }
 
@@ -315,10 +319,11 @@ com_completion()
                fi
                if test $template -eq 0; then
                        make_completion
-                       echo "$result"
+                       printf "%s" "$result"
                        continue
                fi
                template_loop make_completion
+               printf "%s" "$result"
        done
        echo
 }