Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tw/locate.sh
1808 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1989-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# #
19
########################################################################
20
: gnu locate wrapper for tw
21
22
COMMAND=locate
23
case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
24
0123) ARGV0="-a $COMMAND"
25
USAGE=$'
26
[-?
27
@(#)$Id: locate (AT&T Labs Research) 1999-01-23 $
28
]
29
'$USAGE_LICENSE$'
30
[+NAME?locate - locate files in pathname database]
31
[+DESCRIPTION?\blocate\b matches file patterns in a pathname database
32
that is updated daily by \bupdatedb\b(1).]
33
[d:database?File database path.]:[path]
34
[i:ignorecase?Ignore case in all pattern match expressions.]
35
[n:show?Show underlying \btw\b(1) command but do not execute.]
36
37
pattern ...
38
39
[+OPERANDS]{
40
[+pattern?One or more file patterns.
41
/ is matched by pattern metacharacters.]
42
}
43
[+ENVIRONMENT]{
44
[+FINDCODES?Path name of locate database.]
45
[+LOCATE_PATH?Alternate path name of locate database.]
46
}
47
[+FILES]{
48
[+lib/find/codes?Default locate database.]
49
}
50
[+SEE ALSO?\bupdatedb\b(1), \btw\b(1)]
51
'
52
;;
53
*) ARGV0=""
54
USAGE="nd:[path] pattern ..."
55
;;
56
esac
57
58
usage()
59
{
60
OPTIND=0
61
getopts $ARGV0 "$USAGE" OPT '-?'
62
exit 2
63
}
64
65
db=
66
opts=
67
show=
68
while getopts $ARGV0 "$USAGE" OPT
69
do case $OPT in
70
d) db="$db:$OPTARG"
71
;;
72
i) opts="$opts -I"
73
;;
74
n) show="print --"
75
;;
76
*) usage
77
;;
78
esac
79
done
80
case $db in
81
'') db=${LOCATE_PATH} ;;
82
esac
83
case $db in
84
?*) db="-F${db#:}" ;;
85
esac
86
shift $OPTIND-1
87
case $# in
88
0) usage
89
;;
90
1) ;;
91
*) pat=$1
92
while :
93
do shift
94
case $# in
95
0) break ;;
96
esac
97
pat="$pat|$1"
98
done
99
set -- "$pat"
100
;;
101
esac
102
$show tw -d / $opts $db -f "$@"
103
104