{"thread":{"id":"940","subject":"[COGITO PATCH] Fixing \"cg-help typo\" again","startedAt":"2005-06-14T23:32:47Z","lastAt":"2005-06-15T00:17:45Z","messageCount":3,"participants":["Pavel Roskin","Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4957","messageId":"1118791967.3890.11.camel@dv","threadId":"940","inReplyTo":null,"subject":"[COGITO PATCH] Fixing \"cg-help typo\" again","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-06-14T23:32:47Z","receivedAt":"2005-06-14T23:32:47Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\n\"cg-help typo\" is broken again (same symptom - no output) because the\nprint_help() output is piped through colorize(), which never fails.\n\nI don't know any way to get return status of the first command in a\npipeline, so I changed to code to put print_help() output in a variable,\ncheck status and then pipe the variable contents through colorize().\n\nGNU bash can hold indefinitely much data in variables, and we need a few\nkilobytes at most.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/cg-help b/cg-help\n--- a/cg-help\n+++ b/cg-help\n@@ -59,7 +59,8 @@ colorize() {\n \n if [ \"$ARGS\" ]; then\n \tcmd=$(echo \"${ARGS[0]}\" | sed 's/^cg-//')\n-\t( print_help $cmd | colorize ) && exit\n+\thelpdata=\"$(print_help $cmd)\"\n+\t[ \"$?\" = 0 ] && { echo \"$helpdata\" | colorize; exit 0; }\n \techo \"cg-help: no help available for command \\\"${ARGS[0]}\\\"\"\n \techo \"Call cg-help without any arguments for the list of available commands\"\n \texit 1\n\n\n-- \nRegards,\nPavel Roskin\n\n"},{"id":"4958","messageId":"20050614234333.GA17152@diku.dk","threadId":"940","inReplyTo":"1118791967.3890.11.camel@dv","subject":"Re: [COGITO PATCH] Fixing \"cg-help typo\" again","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-14T23:43:33Z","receivedAt":"2005-06-14T23:43:33Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Pavel Roskin <proski@gnu.org> wrote Tue, Jun 14, 2005:\n> Hello!\n\nHi,\n\n> \"cg-help typo\" is broken again (same symptom - no output) because the\n> print_help() output is piped through colorize(), which never fails.\n\nSorry, I broke it in the cg-help colorization patch, and has already\nsent a patch to pasky, off-list I am afraid ...\n> \n> I don't know any way to get return status of the first command in a\n> pipeline, so I changed to code to put print_help() output in a variable,\n> check status and then pipe the variable contents through colorize().\n\nUse the PIPESTATUS aray as in the patch I sent:\n\n@@ -59,7 +59,8 @@ colorize() {\n \n if [ \"$ARGS\" ]; then\n \tcmd=$(echo \"${ARGS[0]}\" | sed 's/^cg-//')\n-\t( print_help $cmd | colorize ) && exit\n+\tprint_help $cmd | colorize\n+\t[ \"${PIPESTATUS[0]}\" -eq 0 ] && exit\n \techo \"cg-help: no help available for command \\\"${ARGS[0]}\\\"\"\n \techo \"Call cg-help without any arguments for the list of available commands\"\n \texit 1\n\n-- \nJonas Fonseca\n"},{"id":"4960","messageId":"1118794665.3890.16.camel@dv","threadId":"940","inReplyTo":"20050614234333.GA17152@diku.dk","subject":"Re: [COGITO PATCH] Fixing \"cg-help typo\" again","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-06-15T00:17:45Z","receivedAt":"2005-06-15T00:17:45Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hi, Jonas!\n\nOn Wed, 2005-06-15 at 01:43 +0200, Jonas Fonseca wrote:\n> Pavel Roskin <proski@gnu.org> wrote Tue, Jun 14, 2005:\n> > I don't know any way to get return status of the first command in a\n> > pipeline, so I changed to code to put print_help() output in a variable,\n> > check status and then pipe the variable contents through colorize().\n> \n> Use the PIPESTATUS aray as in the patch I sent:\n\nOK, your patch is better.\n\nAcked-by: Pavel Roskin <proski@gnu.org>\n\n-- \nRegards,\nPavel Roskin\n\n"}]}