head 1.2; access; symbols SHTOOL_1_0_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.2 date 99.04.29.11.21.06; author rse; state dead; branches; next 1.1; 1.1 date 99.04.29.11.19.34; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.04.29.11.19.34; author rse; state Exp; branches; next ; desc @@ 1.2 log @*** empty log message *** @ text @#!/bin/sh ## ## findprg -- find one or more programs somwhere in PATH ## Copyright (c) 1998-1999 Ralf S. Engelschall ## Originally written for the Apache configuration mechanism ## Usage: findprg [-s] [-pPATH] [] ## # parameters silent=no pathlist=$PATH namelist='' # parse argument line for opt do case $opt in -s ) silent=yes ;; -p* ) pathlist="`echo $opt | cut -c3-`" ;; * ) namelist="$namelist $opt" ;; esac done # check whether the test command supports the -x option testfile="findprg.t.$$" cat >$testfile </dev/null; then minusx="-x" else minusx="-r" fi rm -f $testfile paths="`echo $pathlist |\ sed -e 's/^:/.:/' \ -e 's/::/:.:/g' \ -e 's/:$/:./' \ -e 's/:/ /g'`" # iterate over names for name in $namelist; do # iterate over paths for path in $paths; do if [ $minusx "$path/$name" ] && [ ! -d "$path/$name" ]; then if [ "$silent" != "yes" ]; then echo "$path/$name" fi # found! exit 0 fi done done # not found! exit 1 @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @Import of shtool 1.0.0 @ text @@