File: vpath_find

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (37 lines) | stat: -rwxr-xr-x 851 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
#---------------------------------------------------------------------------#
# Copyright (C) 1995 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
#
# vpath_find:
#	Find the correct location for files based on the VPATH environment
#	variable.
#
# Usage: vpath_find <files>...
#
exit_status=0
VPATHS="`echo "$VPATH" | sed 's/:/ /'`"
for file in "$@"; do
	found=false
	for dir in "" $VPATHS; do
		if [ "$dir" = "" ]; then
			f="$file"
		else
			f="$dir/$file"
		fi
		if [ -f $f ]; then
			echo $f
			found=true
			break
		fi
	done
	if $found; then
		:
	else
		echo "`basename $0`: cannot find $file" 1>&2
		exit_status=1
	fi
done
exit $exit_status