]> diplodocus.org Git - nmh/blob - etc/mhn.find.sh
Formatting cleanup.
[nmh] / etc / mhn.find.sh
1 #! /bin/sh
2 #
3 # mhn.find.sh -- check if a particular command is available
4 #
5
6 if test -z "$2"; then
7 echo "usage: mhn.find.sh search-path program" 1>&2
8 exit 1
9 fi
10
11 # PATH to search for programs
12 SEARCHPATH=$1
13
14 # program to search for
15 PROGRAM=$2
16
17 PGM= oIFS="$IFS" IFS=":"
18 for A in $SEARCHPATH; do
19
20 # skip the directories `.' and `..'
21 if test "$A" = "." -o "$A" = ".."; then
22 continue
23 fi
24
25 # if program was found in /usr/local/bin, then
26 # just echo program name, else echo full pathname
27 if test -f "$A/$PROGRAM"; then
28 if test "$A" = "/usr/local/bin"; then
29 PGM="$PROGRAM"
30 else
31 PGM="$A/$PROGRAM"
32 fi
33
34 echo "$PGM"
35 exit 0
36 fi
37 done
38 IFS="$oIFS"
39