git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Pavel Roskin <proski@gnu.org>
Cc: git <git@vger.kernel.org>
Subject: Re: [COGITO PATCH] Optimized print_help()
Date: Wed, 15 Jun 2005 02:00:01 +0200	[thread overview]
Message-ID: <20050615000001.GB17152@diku.dk> (raw)
In-Reply-To: <1118791576.3890.4.camel@dv>

Pavel Roskin <proski@gnu.org> wrote Tue, Jun 14, 2005:
> 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

Shouldn't $toolpath be quoted here to make it safer? Although it seems
the make install don't handle irregular toolpaths at the moment.

>  	echo
> -	cat $(which cg-$1) | sed -n '3,/^$/s/^# *//p'
> +	cat $toolpath | sed -n '3,/^$/s/^# *//p'

What about also removing UUOC from this line ...

	sed -n '3,/^$/s/^# *//p' < "$toolpath"

>  	exit
>  }

-- 
Jonas Fonseca

  reply	other threads:[~2005-06-14 23:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14 23:26 [COGITO PATCH] Optimized print_help() Pavel Roskin
2005-06-15  0:00 ` Jonas Fonseca [this message]
2005-06-15  0:33   ` Pavel Roskin
2005-06-15 18:58     ` Rene Scharfe
2005-06-15 21:14       ` Pavel Roskin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050615000001.GB17152@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=proski@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).