[COGITO PATCH] Fixing "cg-help typo" again

From: Pavel Roskin <proski@gnu.org>
Date: 2005-06-15 09:32:47
Hello!

"cg-help typo" is broken again (same symptom - no output) because the
print_help() output is piped through colorize(), which never fails.

I don't know any way to get return status of the first command in a
pipeline, so I changed to code to put print_help() output in a variable,
check status and then pipe the variable contents through colorize().

GNU bash can hold indefinitely much data in variables, and we need a few
kilobytes at most.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/cg-help b/cg-help
--- a/cg-help
+++ b/cg-help
@@ -59,7 +59,8 @@ colorize() {
 
 if [ "$ARGS" ]; then
 	cmd=$(echo "${ARGS[0]}" | sed 's/^cg-//')
-	( print_help $cmd | colorize ) && exit
+	helpdata="$(print_help $cmd)"
+	[ "$?" = 0 ] && { echo "$helpdata" | colorize; exit 0; }
 	echo "cg-help: no help available for command \"${ARGS[0]}\""
 	echo "Call cg-help without any arguments for the list of available commands"
 	exit 1


-- 
Regards,
Pavel Roskin

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed Jun 15 09:32:58 2005

This archive was generated by hypermail 2.1.8 : 2005-06-15 09:32:59 EST