From 6f70ad579fef9eef027991dae6b1d4fc62510588 Mon Sep 17 00:00:00 2001 From: Ruslan Kiianchuk Date: Sat, 7 Nov 2015 14:28:26 -0800 Subject: Fix `find_program` function to be less fragile Look for executable path using system utility `which` instead of fragile regular expressions. See $447 for details. Also see discussion in [neovim](https://github.com/neovim/neovim/issues/3620#issuecomment-154757577) issues. --- configure | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/configure b/configure index bd962edf..83818bf1 100755 --- a/configure +++ b/configure @@ -71,26 +71,7 @@ EOF # Helper functions find_program() { - path="$PATH" - item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" - path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" - found="no" - while [ -n "$item" ] - do - if [ -f "$item/$1" ] - then - found="yes" - break - fi - item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" - path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" - done - if [ "$found" = "yes" ] - then - echo "$item" - else - echo "" - fi + which "$1" 2>/dev/null } die() { -- cgit v1.2.3-55-g6feb From 62017cc5a39a0298a3227ebb6182fd83f28b5e22 Mon Sep 17 00:00:00 2001 From: Ruslan Kiianchuk Date: Sat, 7 Nov 2015 19:02:08 -0800 Subject: Use `command -v` for obtaining executable path. Seems like `command -v` is defined by POSIX and therefore should be compatible with all POSIX OSes. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 83818bf1..8b99b2ae 100755 --- a/configure +++ b/configure @@ -71,7 +71,7 @@ EOF # Helper functions find_program() { - which "$1" 2>/dev/null + command -v "$1" 2>/dev/null } die() { -- cgit v1.2.3-55-g6feb