git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jonas Fonseca <fonseca@diku.dk>
Date
Jun 14, 2005, 23:43 UTC
Message-ID
<20050614234333.GA17152@diku.dk>
In-Reply-To
<1118791967.3890.11.camel@dv>
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
Previous: Pavel RoskinNext: Pavel Roskin
Message 2 of 3 in “Fixing "cg-help typo" again”
  1. Fixing "cg-help typo" againPavel Roskin, Jun 14, 2005
  2. Jonas FonsecaJun 14, 2005
  3. Pavel RoskinJun 15, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.