* [COGITO PATCH] Fixing "cg-help typo" again
@ 2005-06-14 23:32 Pavel Roskin
2005-06-14 23:43 ` Jonas Fonseca
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Roskin @ 2005-06-14 23:32 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [COGITO PATCH] Fixing "cg-help typo" again
2005-06-14 23:32 [COGITO PATCH] Fixing "cg-help typo" again Pavel Roskin
@ 2005-06-14 23:43 ` Jonas Fonseca
2005-06-15 0:17 ` Pavel Roskin
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Fonseca @ 2005-06-14 23:43 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
Pavel Roskin <proski@gnu.org> wrote Tue, Jun 14, 2005:
> Hello!
Hi,
> "cg-help typo" is broken again (same symptom - no output) because the
> print_help() output is piped through colorize(), which never fails.
Sorry, I broke it in the cg-help colorization patch, and has already
sent a patch to pasky, off-list I am afraid ...
>
> 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().
Use the PIPESTATUS aray as in the patch I sent:
@@ -59,7 +59,8 @@ colorize() {
if [ "$ARGS" ]; then
cmd=$(echo "${ARGS[0]}" | sed 's/^cg-//')
- ( print_help $cmd | colorize ) && exit
+ print_help $cmd | colorize
+ [ "${PIPESTATUS[0]}" -eq 0 ] && exit
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
--
Jonas Fonseca
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [COGITO PATCH] Fixing "cg-help typo" again
2005-06-14 23:43 ` Jonas Fonseca
@ 2005-06-15 0:17 ` Pavel Roskin
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Roskin @ 2005-06-15 0:17 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: git
Hi, Jonas!
On Wed, 2005-06-15 at 01:43 +0200, Jonas Fonseca wrote:
> Pavel Roskin <proski@gnu.org> wrote Tue, Jun 14, 2005:
> > 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().
>
> Use the PIPESTATUS aray as in the patch I sent:
OK, your patch is better.
Acked-by: Pavel Roskin <proski@gnu.org>
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-15 0:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-14 23:32 [COGITO PATCH] Fixing "cg-help typo" again Pavel Roskin
2005-06-14 23:43 ` Jonas Fonseca
2005-06-15 0:17 ` Pavel Roskin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).