From: Andre Noll Date: Thu, 28 Jun 2012 00:51:28 +0000 (+0200) Subject: command_util: Avoid empty output lines. X-Git-Tag: v0.4.11~10^2~6 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3792a24ac9bb2ee3ea1505c18b3b9ff27db47287;p=paraslash.git command_util: Avoid empty output lines. 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. --- diff --git a/command_util.sh b/command_util.sh index 563ab1a2..b3b8804c 100755 --- a/command_util.sh +++ b/command_util.sh @@ -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 }