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

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

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Jul 6, 2006, 13:58 UTC
Message-ID
<E1FyUNT-0007Ko-JR@moooo.ath.cx>
In-Reply-To
<20060706161011.ccc2ea1c.tihirvon@gmail.com>
Show 20 quoted lines
> "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).

Previous: Dennis StosbergNext: Gerrit Pape
Message 5 of 14 in “configure: Add test for Perl”
  1. 1/3 configure: Add test for PerlDennis Stosberg, Jul 6, 2006
  2. Randal L. SchwartzJul 6, 2006
  3. Timo HirvonenJul 6, 2006
  4. Dennis StosbergJul 6, 2006
  5. Matthias LederhoferJul 6, 2006
  6. Gerrit PapeJul 6, 2006
  7. Dennis StosbergJul 6, 2006
  8. Timo HirvonenJul 6, 2006
  9. Dennis StosbergJul 6, 2006
  10. Petr BaudisJul 7, 2006
  11. Junio C HamanoJul 7, 2006
  12. Timo HirvonenJul 7, 2006
  13. Alex RiesenJul 6, 2006
  14. Dennis StosbergJul 6, 2006

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.