-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSystemFind
executable file
·56 lines (49 loc) · 2.06 KB
/
SystemFind
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
#!/bin/bash
### Imports ###################################################################
source ScriptFunctions
Import OptionParser
### Options ###################################################################
scriptDescription="Special 'find' utility for searches in the ${goboSystem} hierarchy"
scriptCredits="Copyright (C) 2003-2005 Hisham Muhammad. Released under the GNU GPL."
helpOnNoArguments=yes
scriptUsage="[<flags>] <search_pattern>"
scriptExample="-i -l freetype"
scriptNotes="If no flags are set, all four system locations are scanned."
Add_Option_Boolean "e" "executables" "Search for executables in ${goboExecutables}."
Add_Option_Boolean "l" "libraries" "Search for libraries in ${goboLibraries}."
Add_Option_Boolean "i" "headers" "Search for include headers in ${goboHeaders}."
Add_Option_Boolean "s" "settings" "Search for settings in ${goboSettings}."
Add_Option_Boolean "m" "manuals" "Search for settings in ${goboManuals}."
Add_Option_Boolean "q" "quick" "Scan symlinks in /System only (may not find all files)."
Parse_Options "$@"
### Operation #################################################################
if Boolean "quick"
then searchlinks=
else searchlinks=-L
fi
{
function FindInPath() {
Boolean "$3" && {
find $searchlinks "$2" -name "*$1*"
usedOptions=yes
}
}
usedOptions=no
argument="$(Arg 1)"
FindInPath "$argument" "${goboExecutables}" "executables"
FindInPath "$argument" "${goboLibraries}" "libraries"
FindInPath "$argument" "${goboHeaders}" "headers"
FindInPath "$argument" "${goboSettings}" "settings"
FindInPath "$argument" "${goboManuals}" "manuals"
if [ "$usedOptions" = "no" ]
then
find $searchlinks "${goboExecutables}" -name "*$argument*"
find $searchlinks "${goboLibraries}" -name "*$argument*"
find $searchlinks "${goboHeaders}" -name "*$argument*"
find $searchlinks "${goboSettings}" -name "*$argument*"
find $searchlinks "${goboManuals}" -name "*$argument*"
fi
} | while read i
do
readlink -f "$i"
done | sort | uniq