diff options
author | Ruslan Kiianchuk <ruslan.kiianchuk@gmail.com> | 2015-11-07 14:28:26 -0800 |
---|---|---|
committer | Ruslan Kiianchuk <ruslan.kiianchuk@gmail.com> | 2015-11-07 14:28:26 -0800 |
commit | 6f70ad579fef9eef027991dae6b1d4fc62510588 (patch) | |
tree | 80a21f341743f90f6eb6d593f9be501441a44a49 /configure | |
parent | 9c99043149e7578fbbfedbbdc7950a3c1f61ba6e (diff) | |
download | luarocks-6f70ad579fef9eef027991dae6b1d4fc62510588.tar.gz luarocks-6f70ad579fef9eef027991dae6b1d4fc62510588.tar.bz2 luarocks-6f70ad579fef9eef027991dae6b1d4fc62510588.zip |
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.
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 21 |
1 files changed, 1 insertions, 20 deletions
@@ -71,26 +71,7 @@ EOF | |||
71 | # Helper functions | 71 | # Helper functions |
72 | 72 | ||
73 | find_program() { | 73 | find_program() { |
74 | path="$PATH" | 74 | which "$1" 2>/dev/null |
75 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
76 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
77 | found="no" | ||
78 | while [ -n "$item" ] | ||
79 | do | ||
80 | if [ -f "$item/$1" ] | ||
81 | then | ||
82 | found="yes" | ||
83 | break | ||
84 | fi | ||
85 | item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`" | ||
86 | path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`" | ||
87 | done | ||
88 | if [ "$found" = "yes" ] | ||
89 | then | ||
90 | echo "$item" | ||
91 | else | ||
92 | echo "" | ||
93 | fi | ||
94 | } | 75 | } |
95 | 76 | ||
96 | die() { | 77 | die() { |