Skip to content

Commit c0a2d90

Browse files
committed
Look for gcc-* anywhere in $PATH. Fixes rbenv#109
1 parent 8e6e237 commit c0a2d90

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

bin/ruby-build

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ require_gcc() {
252252

253253
locate_gcc() {
254254
local gcc gccs
255-
shopt -s nullglob
256-
gccs=( /usr/bin/gcc-* )
257-
shopt -u nullglob
255+
IFS=: gccs=($(gccs_in_path))
258256

259257
verify_gcc "$CC" ||
260258
verify_gcc "$(command -v gcc || true)" || {
@@ -266,6 +264,22 @@ locate_gcc() {
266264
return 1
267265
}
268266

267+
gccs_in_path() {
268+
local gcc path paths
269+
local gccs=()
270+
IFS=: paths=($PATH)
271+
272+
shopt -s nullglob
273+
for path in "${paths[@]}"; do
274+
for gcc in "$path"/gcc-*; do
275+
gccs["${#gccs[@]}"]="$gcc"
276+
done
277+
done
278+
shopt -u nullglob
279+
280+
printf :%s "${gccs[@]}"
281+
}
282+
269283
verify_gcc() {
270284
local gcc="$1"
271285
if [ -z "$gcc" ]; then

0 commit comments

Comments
 (0)