From: Matthias Lederhofer <matled@gmx.net>
To: Timo Hirvonen <tihirvon@gmail.com>
Cc: Dennis Stosberg <dennis@stosberg.net>, git@vger.kernel.org
Subject: Re: [PATCH 1/3] configure: Add test for Perl
Date: Thu, 6 Jul 2006 15:58:47 +0200 [thread overview]
Message-ID: <E1FyUNT-0007Ko-JR@moooo.ath.cx> (raw)
In-Reply-To: <20060706161011.ccc2ea1c.tihirvon@gmail.com>
> "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
> stdout and returns 0. I use this in my own configure scripts:
>
> path_find()
> {
> if test -x "$1"
> then
> echo "$1"
> return 0
> fi
> for i in `echo $PATH | sed 's/:/ /g'`
> do
> if test -x "$i/$1"
> then
> echo "$i/$1"
> return 0
> fi
> done
> return 1
> }
This will not work with spaces in $PATH. I'd do something like this if
cut is portable (I have only freebsd and linux to test):
path_find()
{
path="$PATH"
while [ "$path" != "" ]; do
p="`echo $path | cut -d : -f 1`"
if [ "$p" = "$path" ]; then
path=""
else
path="`echo $path | cut -d : -f 2-`"
fi
if [ -x "$p/$1" ]; then
echo "$p/$1"
return 0
fi
done
return 1
}
Is there any reason to check the current directory first? "which"
doesn't do it for me and without ./ in the front it does not work
(without . is not in $PATH).
next prev parent reply other threads:[~2006-07-06 13:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-06 12:40 [PATCH 1/3] configure: Add test for Perl Dennis Stosberg
2006-07-06 13:03 ` Randal L. Schwartz
2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 13:29 ` Dennis Stosberg
2006-07-06 13:58 ` Matthias Lederhofer [this message]
2006-07-06 14:17 ` Gerrit Pape
2006-07-06 14:25 ` Dennis Stosberg
2006-07-06 14:27 ` Timo Hirvonen
2006-07-06 15:34 ` Dennis Stosberg
2006-07-07 11:06 ` Petr Baudis
2006-07-07 11:20 ` Junio C Hamano
2006-07-07 11:23 ` Timo Hirvonen
2006-07-06 15:40 ` Alex Riesen
2006-07-06 15:44 ` Dennis Stosberg
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=E1FyUNT-0007Ko-JR@moooo.ath.cx \
--to=matled@gmx.net \
--cc=dennis@stosberg.net \
--cc=git@vger.kernel.org \
--cc=tihirvon@gmail.com \
/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).