File: search-path

package info (click to toggle)
debian-installer-utils 1.132%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 916 kB
  • sloc: sh: 988; ansic: 160; makefile: 61
file content (25 lines) | stat: -rwxr-xr-x 454 bytes parent folder | download | duplicates (6)
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
#!/bin/sh
set -e
# A cut-down version of 'which' from debianutils. Returns zero if executable
# $1 is found on $PATH.
PROGRAM="$1"
IFS=:
RET=1
case $PROGRAM in
	*/*)
		if [ -f "$ELEMENT/$PROGRAM" ] && \
		   [ -x "$ELEMENT/$PROGRAM" ]; then
			exit 0
		fi
		;;
	*)
		for ELEMENT in $PATH; do
			if [ -z "$ELEMENT" ]; then ELEMENT=.; fi
			if [ -f "$ELEMENT/$PROGRAM" ] && \
			   [ -x "$ELEMENT/$PROGRAM" ]; then
				exit 0
			fi
		done
		;;
esac
exit 1