summaryrefslogtreecommitdiff
path: root/util/find.sh
blob: d45bea76bec474be94a53c4ee7d037aba6d8bd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

#echo 1>&2
#echo ::: find.sh "$@" 1>&2

while [[ $# -ne 0 ]]; do
    if [[ $1 == /* ]]; then
        unset found

        found=$(echo "${PKG_PATH}:" | while read -r -d ':' path; do
            if [[ -e ${path}$1 ]]; then
                if [[ ${found+@} ]]; then
                    echo -n ':'
                else
                    found=
                fi

                echo -n "${path}$1"
            fi
        done)

        #echo "=== ${found:=$1}" 1>&2
        echo "${found:=$1}"
    else
        echo "$1"
    fi

    shift
done

#echo 1>&2