Re: [PATCH 1/3] configure: Add test for Perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthias Lederhofer <matled@xxxxxxx> wrote:

> 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):

This works at least with SunOS /bin/sh, dash, posh and bash.

path_find()
{
        if test -x "$1"
        then
                echo "$1"
                return 0
        fi
	_ifs="$IFS"
	IFS=:
        for i in $PATH
        do
                if test -x "$i/$1"
                then
			IFS="$_ifs"
                        echo "$i/$1"
                        return 0
                fi
        done
	IFS="$_ifs"
        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).

It is not needed but might be useful if PERL is user configurable
variable and can contain either full path or basename. For example this
code

    test "$PROG" || PROG=prog
    PROG=`path_find "$PROG"`

works with these cases

    $ PROG=/usr/bin/program ./configure
    $ PROG=program-1.2 ./configure

-- 
http://onion.dynserv.net/~timo/
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]