aboutsummaryrefslogtreecommitdiffstats
path: root/examples/functions/inpath
blob: cb4c93da336d2dfc9206f3ebe3316badb11ecba7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
inpath()
{
	local PROG
	path=$(echo $PATH | sed 's/^:/.:/
				s/::/:.:/g
				s/:$/:./
				s/:/ /g')

	for x in $path
	do
		[ -x $x/$1 ] && { PROG=$x/$1; break; }
	done
	[ -n "$PROG" ]
}