git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [COGITO PATCH] Optimized print_help()
@ 2005-06-14 23:26 Pavel Roskin
  2005-06-15  0:00 ` Jonas Fonseca
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Roskin @ 2005-06-14 23:26 UTC (permalink / raw)
  To: git

Hello!

print_help() in cg-Xlib should not be calling "which" 3 times.  It's an
external command.  The patch caches the result in a local variable.

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

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -130,10 +130,11 @@ update_index () {
 
 
 print_help () {
-	which "cg-$1" >/dev/null 2>&1 || exit 1
-	sed -n '/^USAGE=/,0s/.*"\(.*\)"/Usage: \1/p' < $(which cg-$1) 
+	local toolpath=$(which cg-$1 2>/dev/null)
+	[ -z "$toolpath" ] && exit 1
+	sed -n '/^USAGE=/,0s/.*"\(.*\)"/Usage: \1/p' < $toolpath
 	echo
-	cat $(which cg-$1) | sed -n '3,/^$/s/^# *//p'
+	cat $toolpath | sed -n '3,/^$/s/^# *//p'
 	exit
 }
 

-- 
Regards,
Pavel Roskin


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-15 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-14 23:26 [COGITO PATCH] Optimized print_help() Pavel Roskin
2005-06-15  0:00 ` Jonas Fonseca
2005-06-15  0:33   ` Pavel Roskin
2005-06-15 18:58     ` Rene Scharfe
2005-06-15 21:14       ` 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).