File: vile-libdir-path

package info (click to toggle)
vile 9.8za-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,644 kB
  • sloc: ansic: 120,894; lex: 14,981; sh: 4,478; perl: 3,511; cpp: 3,180; makefile: 1,425; awk: 271
file content (57 lines) | stat: -rwxr-xr-x 1,036 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# $Id: vile-libdir-path,v 1.7 2023/01/01 18:00:11 tom Exp $
# Find the given vile helper-program, either in $PATH, or in a related
# lib-directory.  If the program is already in $PATH, echo the existing
# $PATH, but if it is found in a related lib-directory, prepend that to $PATH

failed() {
	echo "?? $*" >&2
	exit 1
}

HELPER=vile-manfilt
[ $# != 0 ] && HELPER="$1"

OK_BIN=no
OK_LIB=

ARCH="`arch 2>/dev/null`"
[ -n "$ARCH" ] || ARCH=.
SAVE="$IFS"
IFS=':'
for dir in ${VILE_LIBDIR_PATH:-$PATH}
do
	if [ -f "$dir"/"$HELPER" ]
	then
		OK_BIN=yes
		break
	elif [ -z "$OK_LIB" ]
	then
		[ -f "$dir/"vile ] || continue
		head=${dir%/*}
		for libs in \
			"$head"/lib \
			"$head"/lib[1-9]* \
			"$head"/lib/*vile \
			"$head"/lib[1-9]*/*vile \
			"$head"/lib/"$ARCH"*/vile
		do
			[ -d "$libs" ] || continue
			if test -f "$libs"/"$HELPER"
			then
				OK_LIB=$libs
			fi
		done
	fi
done
IFS="$SAVE"

if [ $OK_BIN = yes ]
then
	echo "$PATH"
elif [ -n "$OK_LIB" ]
then
	echo "$OK_LIB:$PATH"
else
	failed "cannot find $HELPER"
fi