summaryrefslogtreecommitdiff
path: root/tools/fado/find_program.sh
blob: 77eb53cbe7d268cc218030704bdf78ed0f3d5c2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash

for i in "${@:2}"
    do
        RESULT=$(IFS=:;find $PATH -maxdepth 1 -name "$i" -print -quit 2> /dev/null | grep -o '[^/]*$')
        COUNT=$(echo "$RESULT" | wc -c)

        if [ $COUNT -gt 1 ]
        then
            echo $RESULT
            exit 0
        fi
    done

echo $1
exit 0