glark 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/glark +2 -2
- data/lib/glark.rb +1 -1
- data/lib/glark/app/app.rb +48 -0
- data/lib/glark/app/help.rb +103 -0
- data/lib/glark/app/info/options.rb +84 -0
- data/lib/glark/app/options.rb +201 -0
- data/lib/glark/app/rcfile.rb +49 -0
- data/lib/glark/app/runner.rb +140 -0
- data/lib/glark/app/spec.rb +19 -0
- data/lib/glark/input/filter/criteria_opts.rb +41 -0
- data/lib/glark/input/filter/dir_criteria_opts.rb +37 -0
- data/lib/glark/input/filter/file_criteria_opts.rb +33 -0
- data/lib/glark/input/filter/filter.rb +59 -0
- data/lib/glark/input/filter/options.rb +171 -0
- data/lib/glark/input/options.rb +120 -0
- data/lib/glark/input/range.rb +104 -0
- data/lib/glark/input/spec.rb +39 -0
- data/lib/glark/io/file/archive_file.rb +64 -0
- data/lib/glark/io/file/binary_file.rb +19 -0
- data/lib/glark/io/file/file.rb +57 -0
- data/lib/glark/io/file/gz_file.rb +21 -0
- data/lib/glark/io/file/tar_file.rb +35 -0
- data/lib/glark/io/file/tar_gz_file.rb +52 -0
- data/lib/glark/io/file/zip_file.rb +39 -0
- data/lib/glark/match/and.rb +83 -0
- data/lib/glark/match/and_distance.rb +58 -0
- data/lib/glark/match/compound.rb +34 -0
- data/lib/glark/match/expression.rb +63 -0
- data/lib/glark/match/factory.rb +173 -0
- data/lib/glark/match/ior.rb +20 -0
- data/lib/glark/match/options.rb +74 -0
- data/lib/glark/match/or.rb +41 -0
- data/lib/glark/match/re.rb +81 -0
- data/lib/glark/match/re_factory.rb +44 -0
- data/lib/glark/match/spec.rb +59 -0
- data/lib/glark/match/xor.rb +20 -0
- data/lib/glark/output/binary_file_summary.rb +17 -0
- data/lib/glark/output/common.rb +43 -0
- data/lib/glark/output/context.rb +57 -0
- data/lib/glark/output/count.rb +26 -0
- data/lib/glark/output/file_header.rb +20 -0
- data/lib/glark/output/file_name_only.rb +35 -0
- data/lib/glark/output/formatted.rb +22 -0
- data/lib/glark/output/glark_count.rb +23 -0
- data/lib/glark/output/glark_format.rb +62 -0
- data/lib/glark/output/glark_lines.rb +36 -0
- data/lib/glark/output/grep_count.rb +18 -0
- data/lib/glark/output/grep_lines.rb +42 -0
- data/lib/glark/output/line_status.rb +46 -0
- data/lib/glark/output/lines.rb +100 -0
- data/lib/glark/output/match_list.rb +15 -0
- data/lib/glark/output/options.rb +103 -0
- data/lib/glark/output/results.rb +23 -0
- data/lib/glark/output/spec.rb +105 -0
- data/lib/glark/output/unfiltered_lines.rb +28 -0
- data/lib/glark/util/colors/options.rb +143 -0
- data/lib/glark/util/colors/spec.rb +21 -0
- data/lib/glark/util/highlight.rb +108 -0
- data/lib/glark/util/io/depth.rb +29 -0
- data/lib/glark/util/io/fileset.rb +162 -0
- data/lib/glark/util/io/filter/criteria.rb +49 -0
- data/lib/glark/util/io/filter/filter.rb +10 -0
- data/lib/glark/util/io/lines.rb +117 -0
- data/lib/glark/util/option.rb +34 -0
- data/lib/glark/util/options.rb +12 -0
- data/lib/glark/util/optutil.rb +69 -0
- data/lib/glark/util/timestamper.rb +18 -0
- data/man/glark.1 +1134 -0
- data/test/glark/app/and_test.rb +82 -0
- data/test/glark/app/compound_test.rb +33 -0
- data/test/glark/app/context_test.rb +43 -0
- data/test/glark/app/count_test.rb +89 -0
- data/test/glark/app/dump_test.rb +16 -0
- data/test/glark/app/expression_file_test.rb +22 -0
- data/test/glark/app/extended_regexp_test.rb +17 -0
- data/test/glark/app/extract_matches_test.rb +27 -0
- data/test/glark/app/files_with_match_test.rb +32 -0
- data/test/glark/app/files_without_match_test.rb +26 -0
- data/test/glark/app/filter_test.rb +118 -0
- data/test/glark/app/highlight_test.rb +78 -0
- data/test/glark/app/ignore_case_test.rb +22 -0
- data/test/glark/app/invert_test.rb +49 -0
- data/test/glark/app/ior_test.rb +21 -0
- data/test/glark/app/label_test.rb +28 -0
- data/test/glark/app/line_number_color_test.rb +42 -0
- data/test/glark/app/line_numbers_test.rb +42 -0
- data/test/glark/app/match_limit_test.rb +49 -0
- data/test/glark/app/options_test.rb +722 -0
- data/test/glark/app/range_test.rb +101 -0
- data/test/glark/app/rcfile_test.rb +113 -0
- data/test/glark/app/record_separator_test.rb +32 -0
- data/test/glark/app/regexp_test.rb +48 -0
- data/test/glark/app/tc.rb +92 -0
- data/test/glark/app/text_color_test.rb +31 -0
- data/test/glark/app/whole_lines_test.rb +17 -0
- data/test/glark/app/whole_words_test.rb +42 -0
- data/test/glark/app/xor_test.rb +19 -0
- data/test/glark/input/binary_file_test.rb +0 -0
- data/test/glark/input/directory_test.rb +202 -0
- data/test/glark/input/dirname_test.rb +69 -0
- data/test/glark/input/exclude_matching_test.rb +20 -0
- data/test/glark/input/ext_test.rb +65 -0
- data/test/glark/input/filter/criteria_test.rb +91 -0
- data/test/glark/input/filter/filter_spec_test.rb +27 -0
- data/test/glark/input/filter/filter_test.rb +21 -0
- data/test/glark/input/name_test.rb +75 -0
- data/test/glark/input/path_test.rb +72 -0
- data/test/glark/input/range_test.rb +82 -0
- data/test/glark/input/size_limit_test.rb +51 -0
- data/test/glark/input/split_as_path_test.rb +28 -0
- data/test/glark/match_test.rb +192 -0
- data/test/glark/resources.rb +21 -0
- data/test/glark/tc.rb +37 -0
- data/test/resources/add.rb +10 -0
- data/test/resources/echo.rb +2 -0
- data/test/resources/greet.rb +13 -0
- metadata +198 -28
- data/README +0 -0
- data/bin/jlark +0 -63
- data/lib/glark/expression.rb +0 -440
- data/lib/glark/exprfactory.rb +0 -248
- data/lib/glark/glark.rb +0 -297
- data/lib/glark/help.rb +0 -85
- data/lib/glark/input.rb +0 -183
- data/lib/glark/options.rb +0 -757
- data/lib/glark/output.rb +0 -266
- data/test/lib/glark/glark_test.rb +0 -317
- data/test/lib/glark/options_test.rb +0 -891
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#!ruby -w
|
3
|
+
# vim: set filetype=ruby : set sw=2
|
4
|
+
|
5
|
+
module Glark
|
6
|
+
class Option
|
7
|
+
include Loggable
|
8
|
+
|
9
|
+
def initialize optee
|
10
|
+
@optee = optee
|
11
|
+
end
|
12
|
+
|
13
|
+
def tags
|
14
|
+
[ '--' + rcfield ]
|
15
|
+
end
|
16
|
+
|
17
|
+
def match_rc name, values
|
18
|
+
if name == rcfield
|
19
|
+
values.each do |val|
|
20
|
+
set val
|
21
|
+
end
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_to_option_data optdata
|
27
|
+
optdata << {
|
28
|
+
:tags => tags,
|
29
|
+
:arg => [ argtype ],
|
30
|
+
:set => Proc.new { |pat| set pat }
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'riel/text/ansi/color'
|
5
|
+
|
6
|
+
module Glark
|
7
|
+
module OptionUtil
|
8
|
+
# returns whether the value matches a true value, such as "yes", "true", or "on".
|
9
|
+
def to_boolean value
|
10
|
+
[ "yes", "true", "on" ].include? value.downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
NONE = Object.new
|
14
|
+
|
15
|
+
def set_var name, val
|
16
|
+
instance_variable_set '@' + name.to_s, val
|
17
|
+
end
|
18
|
+
|
19
|
+
def set name, sval = NONE
|
20
|
+
Proc.new { |optval| set_var name, sval == NONE ? optval : sval }
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_opt optdata, varname, tags, val = NONE
|
24
|
+
optdata << {
|
25
|
+
:tags => tags,
|
26
|
+
:set => set(varname, val)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_opt_arg optdata, varname, argtype, tags, val = NONE
|
31
|
+
optdata << {
|
32
|
+
:tags => tags,
|
33
|
+
:arg => [ argtype ],
|
34
|
+
:set => set(varname, val)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_opt_true optdata, varname, tags
|
39
|
+
add_opt optdata, varname, tags, true
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_opt_false optdata, varname, tags
|
43
|
+
add_opt optdata, varname, tags, false
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_opt_str optdata, varname, tags, val = NONE
|
47
|
+
add_opt_arg optdata, varname, :string, tags, val
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_opt_int optdata, varname, tags, val = NONE
|
51
|
+
add_opt_arg optdata, varname, :integer, tags, val
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_opt_blk optdata, tags, &blk
|
55
|
+
optdata << {
|
56
|
+
:tags => tags,
|
57
|
+
:set => blk
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def colorize field, str
|
62
|
+
if field
|
63
|
+
field + str + Text::Color::RESET
|
64
|
+
else
|
65
|
+
str
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
module TimeStamper
|
5
|
+
def stamp msg = self
|
6
|
+
@start ||= Time.new
|
7
|
+
duration = Time.new - @start
|
8
|
+
printf "%10.6f %-20s %s\n", duration, self.class.to_s, msg.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def interval msg = self
|
12
|
+
@last ||= @start
|
13
|
+
last = @last || Time.new
|
14
|
+
@last = Time.new
|
15
|
+
duration = @last - last
|
16
|
+
printf "%10.6f %-20s %s\n", duration, self.class.to_s, msg.to_s
|
17
|
+
end
|
18
|
+
end
|
data/man/glark.1
ADDED
@@ -0,0 +1,1134 @@
|
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
+
.
|
4
|
+
.TH "GLARK" "1" "December 2012" "" ""
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBglark\fR \- Search text files for complex regular expressions
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBglark\fR \fIoptions\fR expression \fIfiles\fR
|
11
|
+
.
|
12
|
+
.SH "DESCRIPTION"
|
13
|
+
\fBGlark\fR searches files for regular expressions\.
|
14
|
+
.
|
15
|
+
.P
|
16
|
+
Similar to \fBgrep\fR, \fBglark\fR supports Perl\-compatible regular expressions, color highlighting of matches, and context around matches\.
|
17
|
+
.
|
18
|
+
.P
|
19
|
+
\fBGlark\fR extends \fBgrep\fR by matching complex expressions, such as "and", "or", and "xor"\.
|
20
|
+
.
|
21
|
+
.P
|
22
|
+
\fBGlark\fR handles file, directory, and path arguments, optionally recursing directories to a certain depth, and processing path arguments as a set of files and directories\. \.svn and \.git subdirectories are automatically excluded\. Binary files are excluded (by default), but can, in the case of compressed or archived files, have their extracted contents be searched\.
|
23
|
+
.
|
24
|
+
.P
|
25
|
+
\fBGlark\fR can use a per\-project configuration file, so different projects can have their own \fBGlark\fR parameters, such as different files to include and exclude for searching, and different colors for pattern highlighting\.
|
26
|
+
.
|
27
|
+
.SH "OPTIONS"
|
28
|
+
For each option of the type \fB\-\-option=ARG\fR, the equivalent \fB\-\-option ARG\fR can be used instead\. Options can also be specified with their unambiguous leading substrings, such as \fB\-\-rec\fR for \fB\-\-recurse\fR\.
|
29
|
+
.
|
30
|
+
.SS "INPUT"
|
31
|
+
.
|
32
|
+
.TP
|
33
|
+
\fB\-0[nnn]\fR
|
34
|
+
Use \ennn (octal) as the input record separator\. If nnn is omitted, use \'\en\en\' as the record separator, which treats paragraphs as lines\.
|
35
|
+
.
|
36
|
+
.TP
|
37
|
+
\fB\-d\fR ACTION, \fB\-\-directories\fR=ACTION
|
38
|
+
Directories are processed according to the given \fBACTION\fR, which by default is \fBlist\fR, meaning that each file in the directory will be searched\. If \fBACTION\fR is \fBrecurse\fR (or \fBfind\fR), each file in the given directory and its subdirectories will be searched (equivalent to the \fB\-r\fR option)\. If \fBACTION\fR is \fBskip\fR, directories are not read, and no message is produced\.
|
39
|
+
.
|
40
|
+
.TP
|
41
|
+
\fB\-\-binary\-files\fR=TYPE
|
42
|
+
Specify how to handle binary files\. \fBTYPE\fR may be one of:
|
43
|
+
.
|
44
|
+
.IP
|
45
|
+
\fBbinary\fR: only the name of matching files is printed\.
|
46
|
+
.
|
47
|
+
.IP
|
48
|
+
\fBlist\fR: binary files that contain lists of files (such as tar, tar\.gz, zip and jar files) are searched such that the \fIfile names\fR are searched against\.
|
49
|
+
.
|
50
|
+
.IP
|
51
|
+
\fBread\fR: the decompressed full contents of binary files will be searched\. This supports tar, jar, zip, tar\.gz, tgz and gz files\. Only one level of compression/archiving is handled; thus compressed files within other compressed files are not searched\.
|
52
|
+
.
|
53
|
+
.IP
|
54
|
+
\fBskip\fR or \fBwithout\-match\fR: binary files are skipped\. This is the default\.
|
55
|
+
.
|
56
|
+
.IP
|
57
|
+
\fBtext\fR: binary file are treated as text\. This option may have negative side effects with the terminal, attempting to print non\-printable characters\.
|
58
|
+
.
|
59
|
+
.TP
|
60
|
+
\fB\-\-match\-name\fR=REGEXP
|
61
|
+
Search only files with names that match the given regular expression\. As in find(1), this works on the basename of the file\. The expression can be negated and modified with \fB!\fR and \fBi\fR, such as \fB!/io\e\.[hc]$/i\fR\. This option, and all \fB\-\-match\-\fR and \fB\-\-skip\-\fR options, can be specified multiple times, in which case only files matching \fIany\fR of the given expressions will be searched\.
|
62
|
+
.
|
63
|
+
.TP
|
64
|
+
\fB\-\-skip\-name\fR=REGEXP
|
65
|
+
Do not search files with base names matching the given regular expression\. If this option is specified multiple times, only files matching \fInone\fR of the given expressions will be searched\.
|
66
|
+
.
|
67
|
+
.TP
|
68
|
+
\fB\-\-match\-path\fR=REGEXP
|
69
|
+
Search only files with full names that match the given regular expression\. As in find(1), this works on the path of the file\.
|
70
|
+
.
|
71
|
+
.TP
|
72
|
+
\fB\-\-skip\-path\fR=REGEXP
|
73
|
+
Skip files with full names matching the given regular expression\.
|
74
|
+
.
|
75
|
+
.TP
|
76
|
+
\fB\-\-match\-dirname\fR=REGEXP
|
77
|
+
Search only directories with basenames matching the given expression\.
|
78
|
+
.
|
79
|
+
.TP
|
80
|
+
\fB\-\-skip\-dirname\fR=REGEXP
|
81
|
+
Skip directories with basenames not matching the given expression\. Subdirectories of skipped directories will not be recursed\.
|
82
|
+
.
|
83
|
+
.TP
|
84
|
+
\fB\-\-match\-dirpath\fR=REGEXP
|
85
|
+
Search in and under directories with paths matching the given expression\.
|
86
|
+
.
|
87
|
+
.TP
|
88
|
+
\fB\-\-skip\-dirpath\fR=REGEXP
|
89
|
+
Skip directories with paths matching the given expression\.
|
90
|
+
.
|
91
|
+
.TP
|
92
|
+
\fB\-\-match\-ext\fR=REGEXP
|
93
|
+
Search only files with extensions that match the given regular expression, which should not include the leading dot\.
|
94
|
+
.
|
95
|
+
.TP
|
96
|
+
\fB\-\-skip\-ext\fR=REGEXP
|
97
|
+
Skip files with extensions that match the given regular expression\.
|
98
|
+
.
|
99
|
+
.TP
|
100
|
+
\fB\-M\fR, \fB\-\-exclude\-matching\fR
|
101
|
+
Do not search files whose names match the primary expression\. This can be useful for finding external references to a file, or to a class, assuming that class names match file names\.
|
102
|
+
.
|
103
|
+
.TP
|
104
|
+
\fB\-r\fR, \fB\-\-recurse\fR
|
105
|
+
Recurse through directories\. Equivalent to \fB\-\-directories=recurse\fR\.
|
106
|
+
.
|
107
|
+
.TP
|
108
|
+
\fB\-\-split\-as\-path\fR
|
109
|
+
If a command line argument includes the path separator (such as ":"), the argument will be split by the path separator\. This functionality is useful for using environment variables as input, such as \fB$PATH\fR and \fB$CLASSPATH\fR\. which are automatically split and processed as a list of files and directories\. This option is enabled by default\.
|
110
|
+
.
|
111
|
+
.TP
|
112
|
+
\fB\-\-no\-split\-as\-path\fR
|
113
|
+
Disables splitting arguments as paths\.
|
114
|
+
.
|
115
|
+
.TP
|
116
|
+
\fB\-\-size\-limit\fR=SIZE
|
117
|
+
Limit searches to files no larger than \fBSIZE\fR bytes\. This is useful when running the \fB\-\-recurse\fR option on directories that may contain large files\.
|
118
|
+
.
|
119
|
+
.SS "MATCHING"
|
120
|
+
.
|
121
|
+
.TP
|
122
|
+
\fB\-a\fR NUM expr1 expr2, \fB\-\-and\fR NUM expr1 expr2, \fB\-\-and\fR=NUM expr1 expr2
|
123
|
+
Match both expressions, within \fBNUM\fR lines of each other\. See the \fBEXPRESSIONS\fR section for more information\.
|
124
|
+
.
|
125
|
+
.TP
|
126
|
+
\fB( expr1 \-\-and=NUM expr2 )\fR
|
127
|
+
Same as the above, using infix notation instead of prefix\. Note that depending on your shell, you may have to escape the parentheses\.
|
128
|
+
.
|
129
|
+
.TP
|
130
|
+
\fB\-\-after\fR=NUM[%]
|
131
|
+
Restrict the search to after the given section, which represents either the number of the first line within the valid range, or the percentage of lines to be skipped\. \fB\-\-after=25%\fR means to search the "lower" 25% of each file\. \fB\-\-after=10\fR means to skip the first ten lines of each file\.
|
132
|
+
.
|
133
|
+
.TP
|
134
|
+
\fB\-b\fR NUM[%], \fB\-\-before\fR=NUM[%]
|
135
|
+
Restrict the search to before the given location, which is either the number of the last line within the valid range, or the percentage of lines to be searched\.
|
136
|
+
.
|
137
|
+
.TP
|
138
|
+
\fB\-f\fR FILE, \fB\-\-file\fR=FILE
|
139
|
+
Use the lines in the given file as expressions\. Each line consists of a regular expression\. Complex expressions are supported\.
|
140
|
+
.
|
141
|
+
.TP
|
142
|
+
\fB\-i\fR, \fB\-\-ignore\-case\fR
|
143
|
+
Match regular expressions without regard to case\. The default is case sensitive\.
|
144
|
+
.
|
145
|
+
.TP
|
146
|
+
\fB\-m\fR NUM, \fB\-\-match\-limit\fR=NUM
|
147
|
+
Output only the first \fBNUM\fR matches in each file\.
|
148
|
+
.
|
149
|
+
.TP
|
150
|
+
\fB\-a\fR NUM expr1 expr2, \fB\-\-or\fR NUM expr1 expr2, \fB\-\-or\fR=NUM expr1 expr2
|
151
|
+
Match either expressions\. See the \fBEXPRESSIONS\fR section for more information\.
|
152
|
+
.
|
153
|
+
.TP
|
154
|
+
\fB( expr1 \-\-or=NUM expr2 )\fR
|
155
|
+
Same as the above, using infix notation instead of prefix\.
|
156
|
+
.
|
157
|
+
.TP
|
158
|
+
\fB\-R\fR, \fB\-\-range\fR NUM[%],NUM[%]
|
159
|
+
Restrict the search to the given range of lines, as either line numbers or a percentage of the length of the file\.
|
160
|
+
.
|
161
|
+
.TP
|
162
|
+
\fB\-v\fR, \fB\-\-invert\-match\fR
|
163
|
+
Show lines that do not match the expression\.
|
164
|
+
.
|
165
|
+
.TP
|
166
|
+
\fB\-w\fR, \fB\-\-word\fR, \fB\-\-word\-regexp\fR
|
167
|
+
Put word boundaries around each pattern, thus matching only where the full word(s) occur in the text\. Thus, \fBglark \-w Foo\fR is the same as \fBglark \'/\ebFoo\eb/\'\fR\.
|
168
|
+
.
|
169
|
+
.TP
|
170
|
+
\fB\-x\fR, \fB\-\-line\-regexp\fR
|
171
|
+
Select only where the entire line matches the pattern(s)\.
|
172
|
+
.
|
173
|
+
.TP
|
174
|
+
\fB\-\-xor\fR expr1 expr2
|
175
|
+
Match either of the two expressions, but not both\. See the EXPRESSIONS section for more information\.
|
176
|
+
.
|
177
|
+
.TP
|
178
|
+
\fB( expr1 \-\-xor expr2 )\fR
|
179
|
+
Same as the above, using infix notation instead of prefix\.
|
180
|
+
.
|
181
|
+
.SS "OUTPUT"
|
182
|
+
.
|
183
|
+
.TP
|
184
|
+
\fB\-A\fR NUM, \fB\-\-after\-context\fR=NUM
|
185
|
+
Print \fBNUM\fR lines after a matched expression\.
|
186
|
+
.
|
187
|
+
.TP
|
188
|
+
\fB\-B\fR NUM, \fB\-\-before\-context\fR=NUM
|
189
|
+
Print \fBNUM\fR lines before a matched expression\.
|
190
|
+
.
|
191
|
+
.TP
|
192
|
+
\fB\-C\fR [NUM], \fB\-NUM\fR, \fB\-\-context[=NUM]\fR
|
193
|
+
Output \fBNUM\fR lines of context around a matched expression\. The default is no context\. If no \fBNUM\fR is given for this option, the number of lines of context is 2\.
|
194
|
+
.
|
195
|
+
.TP
|
196
|
+
\fB\-c\fR, \fB\-\-count\fR
|
197
|
+
Instead of normal output, display only the number of matches in each file\.
|
198
|
+
.
|
199
|
+
.TP
|
200
|
+
\fB\-F\fR, \fB\-\-file\-color\fR=COLOR
|
201
|
+
Specify the highlight color for file names\. See the HIGHLIGHTING section for the values that can be used\.
|
202
|
+
.
|
203
|
+
.TP
|
204
|
+
\fB\-\-no\-filter\fR
|
205
|
+
Display all lines, after highlighting matching expressions\. This is useful to see highlighted matches as well as non\-matching lines, essentially a \fB\-\-context\fR of the entire file\.
|
206
|
+
.
|
207
|
+
.TP
|
208
|
+
\fB\-g\fR, \fB\-\-grep\fR
|
209
|
+
Produce output like the (legacy) grep default: file names, no line numbers, and a single line of the match, which will be the first line for matches that span multiple lines\. If the EMACS environment variable is set, this value is set to true\.
|
210
|
+
.
|
211
|
+
.TP
|
212
|
+
\fB\-h\fR, \fB\-\-no\-filename\fR
|
213
|
+
Do not display the names of the files that matched\.
|
214
|
+
.
|
215
|
+
.TP
|
216
|
+
\fB\-H\fR, \fB\-\-with\-filename\fR
|
217
|
+
Display the names of the files that matched\. This is the default behavior\.
|
218
|
+
.
|
219
|
+
.TP
|
220
|
+
\fB\-l\fR, \fB\-\-files\-with\-matches\fR
|
221
|
+
Print only the names of the file that matched the expression\.
|
222
|
+
.
|
223
|
+
.TP
|
224
|
+
\fB\-L\fR, \fB\-\-files\-without\-match\fR
|
225
|
+
Print only the names of the file that did \fBnot\fR match the expression\.
|
226
|
+
.
|
227
|
+
.TP
|
228
|
+
\fB\-\-label\fR=NAME
|
229
|
+
Use \fBNAME\fR as the output file name\. This is useful when reading from standard input, such as glark being piped from an archive listing (tar tvf or jar tvf)\.
|
230
|
+
.
|
231
|
+
.TP
|
232
|
+
\fB\-n\fR, \fB\-\-line\-number\fR
|
233
|
+
Display the line numbers\. This is the default behavior\.
|
234
|
+
.
|
235
|
+
.TP
|
236
|
+
\fB\-N\fR, \fB\-\-no\-line\-number\fR
|
237
|
+
Do not display the line numbers\.
|
238
|
+
.
|
239
|
+
.TP
|
240
|
+
\fB\-\-line\-number\-color\fR=COLOR
|
241
|
+
Specify the highlight color for line numbers\. This defaults to none (no highlighting)\. See the HIGHLIGHTING section for more information\.
|
242
|
+
.
|
243
|
+
.TP
|
244
|
+
\fB\-T\fR, \fB\-\-text\-color\fR=COLOR
|
245
|
+
Specify the highlight color for text\. See the HIGHLIGHTING section for more information\.
|
246
|
+
.
|
247
|
+
.TP
|
248
|
+
\fB\-u\fR, \fB\-\-highlight\fR=FORMAT
|
249
|
+
Enable highlighting\. This is the default behavior\. Format is "single" (one color) or "multi" (different color per regular expression)\. See the HIGHLIGHTING section for more information\.
|
250
|
+
.
|
251
|
+
.TP
|
252
|
+
\fB\-U\fR, \fB\-\-no\-highlight\fR
|
253
|
+
Disable highlighting\.
|
254
|
+
.
|
255
|
+
.TP
|
256
|
+
\fB\-y\fR, \fB\-\-extract\-matches\fR
|
257
|
+
Display only the region that matched, not the entire line\. If the expression contains "backreferences" (i\.e\., expressions bounded by "( \.\.\. )"), then only the portion captured will be displayed, not the entire line\. This option is useful with \fB\-g\fR, which eliminates the default highlighting and display of file names\.
|
258
|
+
.
|
259
|
+
.TP
|
260
|
+
\fB\-Z\fR, \fB\-\-null\fR
|
261
|
+
When in \fB\-l\fR mode, write file names followed by the ASCII NUL character (\'><\') instead of \'\en\'\. This is like \fBfind \.\.\. \-print0\fR, for piping into another command\.
|
262
|
+
.
|
263
|
+
.SS "INFORMATION"
|
264
|
+
.
|
265
|
+
.TP
|
266
|
+
\fB\-?\fR, \fB\-\-help\fR
|
267
|
+
Display the help message\.
|
268
|
+
.
|
269
|
+
.TP
|
270
|
+
\fB\-\-config\fR
|
271
|
+
Display the settings glark is using, and exit\. Since this is run after configuration files are read, this may be useful for determining values of configuration parameters\.
|
272
|
+
.
|
273
|
+
.TP
|
274
|
+
\fB\-\-explain\fR
|
275
|
+
Write the expression in a more legible format, useful for debugging complex expressions\.
|
276
|
+
.
|
277
|
+
.TP
|
278
|
+
\fB\-q\fR, \fB\-\-quiet\fR, \fB\-\-no\-messages\fR
|
279
|
+
Suppress warnings\. By default, warnings are enabled\.
|
280
|
+
.
|
281
|
+
.TP
|
282
|
+
\fB\-V\fR, \fB\-\-version\fR
|
283
|
+
Display version information\.
|
284
|
+
.
|
285
|
+
.TP
|
286
|
+
\fB\-\-verbose\fR
|
287
|
+
Display normally suppressed output, for debugging purposes\.
|
288
|
+
.
|
289
|
+
.SH "FILES"
|
290
|
+
File arguments follow options and the expression to be matched\. Files can be one or more of any of the following:
|
291
|
+
.
|
292
|
+
.TP
|
293
|
+
\fBfile\fR
|
294
|
+
Name of files\.
|
295
|
+
.
|
296
|
+
.TP
|
297
|
+
\fBdirectory\fR
|
298
|
+
Directories under which files are searched\. See the \fB\-\-directories\fR option for controlling whether to match all files \fIin\fR the given directory (the \fBlist\fR value), or to match all files \fIunder\fR the given directory, recursively\.
|
299
|
+
.
|
300
|
+
.IP
|
301
|
+
Files within and subdirectories of a directory are listed in sorted order\.
|
302
|
+
.
|
303
|
+
.IP
|
304
|
+
Directories can also be of the form \fB/usr/lib/\.\.\.\fR, which means to recurse under the given directory\. This can also be \fB\.\.\.\fR, meaning to recurse under the current directory\.
|
305
|
+
.
|
306
|
+
.IP
|
307
|
+
The form \fB/usr/lib/\.\.\.N\fR, where N is a number, restrains recursive searching to the given depth\. A value of 0 means to search only the files in the given directory; a value of 1 means to search the files in the given directory and the immediate subdirectories\. What happens with a value of 2 is left as an exercise for the reader\.
|
308
|
+
.
|
309
|
+
.TP
|
310
|
+
\fB\-\fR
|
311
|
+
Read from standard input\. If no file arguments are specified this is the default\.
|
312
|
+
.
|
313
|
+
.TP
|
314
|
+
\fBpath\fR
|
315
|
+
This is a path, using the path separator for the current OS (\':\' for Linux, \';\' for Windows)\. Each element of the path will be processed as a file or directory\.
|
316
|
+
.
|
317
|
+
.SH "EXPRESSIONS"
|
318
|
+
Regular expressions are expected to be in the Perl/Ruby format\. \fBperldoc perlre\fR has more general information\. The expression may be of either form:
|
319
|
+
.
|
320
|
+
.IP "" 4
|
321
|
+
.
|
322
|
+
.nf
|
323
|
+
|
324
|
+
something
|
325
|
+
/something/
|
326
|
+
.
|
327
|
+
.fi
|
328
|
+
.
|
329
|
+
.IP "" 0
|
330
|
+
.
|
331
|
+
.P
|
332
|
+
There is no difference between the two forms, except that with the latter, one can provide the "ignore case" modifier, thus matching "someThing" and "SoMeThInG":
|
333
|
+
.
|
334
|
+
.IP "" 4
|
335
|
+
.
|
336
|
+
.nf
|
337
|
+
|
338
|
+
% glark /something/i
|
339
|
+
.
|
340
|
+
.fi
|
341
|
+
.
|
342
|
+
.IP "" 0
|
343
|
+
.
|
344
|
+
.P
|
345
|
+
This is redundant with the \fB\-i\fR (\fB\-\-ignore\-case\fR) option\.
|
346
|
+
.
|
347
|
+
.P
|
348
|
+
All regular expression characters and sequences are available, such as "\ew" and "\.*?"\. For example:
|
349
|
+
.
|
350
|
+
.IP "" 4
|
351
|
+
.
|
352
|
+
.nf
|
353
|
+
|
354
|
+
% glark \'\eb[a\-z][^\ed]\ed{1,3}\.*\es*>>\es*\ed+\es*\.*& +\ed{3}\'
|
355
|
+
.
|
356
|
+
.fi
|
357
|
+
.
|
358
|
+
.IP "" 0
|
359
|
+
.
|
360
|
+
.P
|
361
|
+
If the \fB\-\-and\fR and \fB\-\-or\fR options are not used, the last non\-option is considered to be the expression to be matched\. In the following, "printf" is used as the expression\. Note that in non\-quiet mode, a warning will result if the expression exists as a file, to show when the expression may have been erroneously omitted\.
|
362
|
+
.
|
363
|
+
.IP "" 4
|
364
|
+
.
|
365
|
+
.nf
|
366
|
+
|
367
|
+
% glark \-w printf *\.c
|
368
|
+
.
|
369
|
+
.fi
|
370
|
+
.
|
371
|
+
.IP "" 0
|
372
|
+
.
|
373
|
+
.P
|
374
|
+
POSIX character classes (e\.g\., [[:alpha:]]) are also supported\.
|
375
|
+
.
|
376
|
+
.SS "COMPLEX EXPRESSIONS"
|
377
|
+
Complex expressions combine regular expressions (and complex expressions themselves) with logical AND, OR, and XOR operators\. Both prefix and infix notations are supported\.
|
378
|
+
.
|
379
|
+
.TP
|
380
|
+
\fB\-a\fR NUM expr1 expr2, \fB\-\-and=NUM\fR expr1 expr2, \fB\-\-end\-of\-and\fR, \fB( expr1 \-\-and NUM expr2 )\fR
|
381
|
+
Match both of the two expressions, within \fBNUM\fR lines of each other\. The forms \fB\-aNUM\fR and \fB\-\-and=NUM\fR are also supported\. In the prefix syntax, \fB\-\-end\-of\-and\fR is optional\.
|
382
|
+
.
|
383
|
+
.IP
|
384
|
+
If \fBNUM\fR is \-1 (negative one), the distance is considered "infinite", so the condition is satisfied if both expressions match within the same file\.
|
385
|
+
.
|
386
|
+
.IP
|
387
|
+
If \fBNUM\fR is 0 (zero), the condition is satisfied if both expressions match on the same line\.
|
388
|
+
.
|
389
|
+
.IP
|
390
|
+
If the \fB\-\-and\fR option is used and the follow argument is not numeric, then the value defaults to zero\.
|
391
|
+
.
|
392
|
+
.IP
|
393
|
+
A warning will result if the value given in the number position does not appear to be numeric\.
|
394
|
+
.
|
395
|
+
.TP
|
396
|
+
\fB\-o\fR expr1 expr2, \fB\-\-or\fR expr1 expr2 \fB\-\-end\-of\-or\fR, \fB( expr1 \-\-or expr2 )\fR
|
397
|
+
Match either of the two expressions\. As with the \fB\-\-and\fR option, the two forms are equivalent, and \fB\-\-end\-of\-or\fR is optional\.
|
398
|
+
.
|
399
|
+
.TP
|
400
|
+
\fB\-\-xor\fR expr1 expr2 \fB\-\-end\-of\-xor\fR, \fB( expr1 \-\-xor expr2 )\fR
|
401
|
+
Match either of the two expressions, but not both\. \fB\-\-end\-of\-xor\fR is optional\.
|
402
|
+
.
|
403
|
+
.SS "NEGATED EXPRESSIONS"
|
404
|
+
Regular expressions can be negated, by being prefixed with \'!\', and using the \'/\' quote characters around the expression, such as:
|
405
|
+
.
|
406
|
+
.IP "" 4
|
407
|
+
.
|
408
|
+
.nf
|
409
|
+
|
410
|
+
!/this/
|
411
|
+
.
|
412
|
+
.fi
|
413
|
+
.
|
414
|
+
.IP "" 0
|
415
|
+
.
|
416
|
+
.P
|
417
|
+
This has the effect of "match anything other than \'this\'"\. For a single expression, this is no different than the \fB\-v\fR (\fB\-\-invert\-match\fR) option, but it can be useful in complex expressions, such as:
|
418
|
+
.
|
419
|
+
.IP "" 4
|
420
|
+
.
|
421
|
+
.nf
|
422
|
+
|
423
|
+
\-\-and 0 this \'!/that/\'
|
424
|
+
.
|
425
|
+
.fi
|
426
|
+
.
|
427
|
+
.IP "" 0
|
428
|
+
.
|
429
|
+
.P
|
430
|
+
which means "match a line that has "this", but not "that"\.
|
431
|
+
.
|
432
|
+
.SH "HIGHLIGHTING"
|
433
|
+
On terminals that support ANSI escape sequences, matching patterns and file names can be highlighted for the foreground and/or background\. Colors are denoted by name, from the following list, or by RGB value, in the form RRGGBB\.
|
434
|
+
.
|
435
|
+
.IP "" 4
|
436
|
+
.
|
437
|
+
.nf
|
438
|
+
|
439
|
+
black
|
440
|
+
blue
|
441
|
+
cyan
|
442
|
+
green
|
443
|
+
magenta
|
444
|
+
red
|
445
|
+
white
|
446
|
+
yellow
|
447
|
+
.
|
448
|
+
.fi
|
449
|
+
.
|
450
|
+
.IP "" 0
|
451
|
+
.
|
452
|
+
.P
|
453
|
+
The foreground may have any number of the following modifiers applied:
|
454
|
+
.
|
455
|
+
.IP "" 4
|
456
|
+
.
|
457
|
+
.nf
|
458
|
+
|
459
|
+
blink
|
460
|
+
bold
|
461
|
+
concealed
|
462
|
+
negative
|
463
|
+
underline
|
464
|
+
underscore
|
465
|
+
.
|
466
|
+
.fi
|
467
|
+
.
|
468
|
+
.IP "" 0
|
469
|
+
.
|
470
|
+
.P
|
471
|
+
The format is "MODIFIERS FOREGROUND on BACKGROUND"\. For example:
|
472
|
+
.
|
473
|
+
.IP "" 4
|
474
|
+
.
|
475
|
+
.nf
|
476
|
+
|
477
|
+
red
|
478
|
+
black on yellow (the default for patterns)
|
479
|
+
bold (the default for file names)
|
480
|
+
green on white
|
481
|
+
AE22D9
|
482
|
+
f2331a on 2a3f44
|
483
|
+
bold underline red on 88a72d
|
484
|
+
.
|
485
|
+
.fi
|
486
|
+
.
|
487
|
+
.IP "" 0
|
488
|
+
.
|
489
|
+
.P
|
490
|
+
By default text is highlighted as black on yellow\. File names are written in bold\.
|
491
|
+
.
|
492
|
+
.SH "EXAMPLES"
|
493
|
+
.
|
494
|
+
.SS "BASIC USAGE"
|
495
|
+
.
|
496
|
+
.TP
|
497
|
+
\fBglark format *\.h\fR
|
498
|
+
Searches for "format" in the local \.h files\.
|
499
|
+
.
|
500
|
+
.TP
|
501
|
+
\fBglark \-\-ignore\-case format *\.h\fR
|
502
|
+
Searches for "format" without regard to case\. Short form:
|
503
|
+
.
|
504
|
+
.IP
|
505
|
+
\fBglark \-i format *\.h\fR
|
506
|
+
.
|
507
|
+
.TP
|
508
|
+
\fBglark \-\-context=6 format *\.h\fR
|
509
|
+
Produces 6 lines of context around any match for "format"\. Short forms:
|
510
|
+
.
|
511
|
+
.IP
|
512
|
+
\fBglark \-C 6 format *\.h\fR \fBglark \-6 format *\.h\fR
|
513
|
+
.
|
514
|
+
.TP
|
515
|
+
\fBglark \-\-exclude\-matching Object *\.java\fR
|
516
|
+
Find references to "Object", excluding the files whose names match "Object"\. Thus, SessionBean\.java would be searched; EJBObject\.java would not\. Short form:
|
517
|
+
.
|
518
|
+
.IP
|
519
|
+
\fBglark \-M Object *\.java\fR
|
520
|
+
.
|
521
|
+
.TP
|
522
|
+
\fBglark \-N \-h \-\-context=0 \-\-extract\-matches \'(\ew+)\e\.printStackTrace\e(\.*\e)\' *\.java\fR
|
523
|
+
Show only the variable name of exceptions that are dumped\. Short form:
|
524
|
+
.
|
525
|
+
.IP
|
526
|
+
\fBglark \-gy \'(\ew+)\e\.printStackTrace\e\e(\.\e*\e\e)\' *\.java\fR
|
527
|
+
.
|
528
|
+
.TP
|
529
|
+
\fB% who| glark \-gy \'^(\eS+)\es+\eS+\es*May 15\'\fR
|
530
|
+
Display only the names of users who logged in today\.
|
531
|
+
.
|
532
|
+
.TP
|
533
|
+
\fBglark \-l \'\eb\ew{25,}\eb\' *\.txt\fR
|
534
|
+
Display (only) the names of the text files that contain "words" at least 25 characters long\.
|
535
|
+
.
|
536
|
+
.TP
|
537
|
+
\fBglark \-\-files\-without\-match \'"\ew+"\'\fR
|
538
|
+
Display (only) the names of the files that do not contain strings consisting of a single word\. Short form:
|
539
|
+
.
|
540
|
+
.IP
|
541
|
+
\fBglark \-L \'"\ew+"\'\fR
|
542
|
+
.
|
543
|
+
.TP
|
544
|
+
\fBglark \-\-text\-color "red on white" \'\eb[[:digit:]]{5}\eb\' *\.c\fR
|
545
|
+
Display (in red text on a white background) occurrences of exactly 5 digits\.
|
546
|
+
.
|
547
|
+
.IP
|
548
|
+
See the HIGHLIGHTING section for valid colors and modifiers\.
|
549
|
+
.
|
550
|
+
.SS "COMPLEX EXPRESSIONS"
|
551
|
+
.
|
552
|
+
.TP
|
553
|
+
\fBglark \-\-or format print *\.h"\fR
|
554
|
+
Searches for either "printf" or "format"\. Short form:
|
555
|
+
.
|
556
|
+
.IP
|
557
|
+
\fBglark \-o format print *\.h\fR
|
558
|
+
.
|
559
|
+
.TP
|
560
|
+
\fBglark \-\-and 4 printf format *\.c *\.h\fR
|
561
|
+
Searches for both "printf" or "format" within 4 lines of each other\. Short form:
|
562
|
+
.
|
563
|
+
.IP
|
564
|
+
\fBglark \-a 4 printf format *\.c *\.h\fR
|
565
|
+
.
|
566
|
+
.TP
|
567
|
+
\fBglark \-\-context=3 \-\-and 0 printf format *\.c"\fR
|
568
|
+
Searches for both "printf" or "format" on the same line ("within 0 lines of each other")\. Three lines of context are displayed around any matches\. Short form:
|
569
|
+
.
|
570
|
+
.IP
|
571
|
+
\fBglark \-3 \-a 0 printf format *\.c\fR
|
572
|
+
.
|
573
|
+
.TP
|
574
|
+
\fBglark \-8 \-i \-a 15 \-a 2 pthx \'\e\.\e\.\e\.\' \-o \'va_\ew+t\' die *\.c\fR
|
575
|
+
In order of the options: produces 8 lines of context around case insensitive matches of ("phtx" within 2 lines of \'\.\.\.\' (literal)) within 15 lines of (either "va_\ew+t" or "die")\.
|
576
|
+
.
|
577
|
+
.TP
|
578
|
+
\fBglark \-\-and \-1 \'#define\es+YIELD\' \'#define\es+dTHR\' *\.h\fR
|
579
|
+
Looks for "#define\es+YIELD" within the same file (\-1 == "infinite distance") of "#define\es+dTHR"\. Short form:
|
580
|
+
.
|
581
|
+
.IP
|
582
|
+
\fBglark \-a \-1 \'#define\es+YIELD\' \'#define\es+dTHR\' *\.h\fR
|
583
|
+
.
|
584
|
+
.SS "RANGE LIMITING"
|
585
|
+
.
|
586
|
+
.TP
|
587
|
+
\fBglark \-\-before 50% cout *\.cpp\fR
|
588
|
+
Find references to "cout", within the first half of the file\. Short form:
|
589
|
+
.
|
590
|
+
.IP
|
591
|
+
\fBglark \-b 50% cout *\.cpp\fR
|
592
|
+
.
|
593
|
+
.TP
|
594
|
+
\fBglark \-\-after 20 cout *\.cpp\fR
|
595
|
+
Find references to "cout", starting at the 20th line in the file\. Short form:
|
596
|
+
.
|
597
|
+
.IP
|
598
|
+
\fBglark \-b 50% cout *\.cpp\fR
|
599
|
+
.
|
600
|
+
.TP
|
601
|
+
\fBglark \-\-range 20,50% cout *\.cpp\fR
|
602
|
+
Find references to "cout", in the first half of the file, after the 20th line\. Short form:
|
603
|
+
.
|
604
|
+
.IP
|
605
|
+
\fBglark \-R 20,50% cout *\.cpp\fR
|
606
|
+
.
|
607
|
+
.SS "FILE PROCESSING"
|
608
|
+
.
|
609
|
+
.TP
|
610
|
+
\fBglark \-r print \.\fR
|
611
|
+
Search for "print" in all files at and below the current directory\. Equivalently, this can be:
|
612
|
+
.
|
613
|
+
.IP
|
614
|
+
\fBglark print \.\.\.\fR
|
615
|
+
.
|
616
|
+
.TP
|
617
|
+
\fBglark \-\-match\-path=\'/\e\.java$/\' \-r println org\fR
|
618
|
+
Search for "println" in all Java files at and below the "org" directory\.
|
619
|
+
.
|
620
|
+
.TP
|
621
|
+
\fBglark \-\-match\-name=\'!/CVS/\' \-r \'\eb\ed\ed:\ed\ed:\ed\ed\eb\' \.\fR
|
622
|
+
Search for a time pattern in all files without "CVS" in their basenames\.
|
623
|
+
.
|
624
|
+
.TP
|
625
|
+
\fBglark \-\-size\-limit=1024 \-r main \-r \.\fR
|
626
|
+
Search for "main" in files no larger than 1024 bytes\.
|
627
|
+
.
|
628
|
+
.TP
|
629
|
+
\fBglark Regexp /usr/lib/ruby/1\.9\.1/\.\.\.\fR
|
630
|
+
Search for "Regexp" in all files \fIin\fR and \fIunder\fR /usr/lib/ruby/1\.9\.1, with no depth limit\.
|
631
|
+
.
|
632
|
+
.TP
|
633
|
+
\fBglark Regexp /usr/lib/ruby/1\.9\.1/\.\.\.0\fR
|
634
|
+
Search for "Regexp" in all files \fIin\fR /usr/lib/ruby/1\.9\.1\. This is equivalent to:
|
635
|
+
.
|
636
|
+
.IP
|
637
|
+
\fBglark Regexp /usr/lib/ruby/1\.9\.1\fR
|
638
|
+
.
|
639
|
+
.TP
|
640
|
+
\fBglark Regexp /usr/lib/ruby/1\.9\.1/\.\.\.2\fR
|
641
|
+
Search for "Regexp" in all files \fIin\fR /usr/lib/ruby/1\.9\.1 and two levels of subdirectories underneath\.
|
642
|
+
.
|
643
|
+
.TP
|
644
|
+
\fBglark \-\-match\-name \'http\.*\' Regexp /usr/lib/ruby/1\.9\.1/\.\.\.\fR
|
645
|
+
Search for "Regexp" in all files \fIunder\fR /usr/lib/ruby/1\.9\.1 with a name starting with \'http\'\.
|
646
|
+
.
|
647
|
+
.TP
|
648
|
+
\fBglark connect \-\fR
|
649
|
+
Search standard input for "connect"\.
|
650
|
+
.
|
651
|
+
.TP
|
652
|
+
\fBfor i in *\.jar; do jar tf $i | glark \-\-label=$i Exception; done\fR
|
653
|
+
Search the files for \'Exception\', displaying the jar file name instead of the standard input marker (\'\-\')\. An equivalent is:
|
654
|
+
.
|
655
|
+
.IP
|
656
|
+
\fBglark \-\-binary\-files=list Exception *\.jar\fR
|
657
|
+
.
|
658
|
+
.SS "ADVANCED USAGE"
|
659
|
+
.
|
660
|
+
.TP
|
661
|
+
\fBglark \-\-explain \-\-match\-name \'c\.*\e\.rb$\' \-\-and=5 Regexp \-\-xor parse \-\-and=3 boundary quote /usr/lib/ruby/1\.9\.1/\.\.\.2\fR:
|
662
|
+
.
|
663
|
+
.IP
|
664
|
+
As shown by the \fB\-\-explain\fR options:
|
665
|
+
.
|
666
|
+
.IP "" 4
|
667
|
+
.
|
668
|
+
.nf
|
669
|
+
|
670
|
+
within 5 lines of each other:
|
671
|
+
/Regexp/
|
672
|
+
and
|
673
|
+
only one of:
|
674
|
+
/parse/
|
675
|
+
xor
|
676
|
+
within 3 lines of each other:
|
677
|
+
/boundary/
|
678
|
+
and
|
679
|
+
/quote/
|
680
|
+
.
|
681
|
+
.fi
|
682
|
+
.
|
683
|
+
.IP "" 0
|
684
|
+
.
|
685
|
+
.IP
|
686
|
+
Search for the given expression under the Ruby 1\.9\.1 tree, for \.rb files starting with \'c\'\.
|
687
|
+
.
|
688
|
+
.SH "ENVIRONMENT"
|
689
|
+
.
|
690
|
+
.TP
|
691
|
+
\fBGLARKOPTS\fR
|
692
|
+
A string of whitespace\-delimited options\. Because of parsing constraints, should probably not contain complex regular expressions\.
|
693
|
+
.
|
694
|
+
.TP
|
695
|
+
\fB$HOME/\.glarkrc\fR
|
696
|
+
A resource file, containing name/value pairs, separated by either \':\' or \'=\'\. The valid fields of a \.glarkrc file are as follows, with example values:
|
697
|
+
.
|
698
|
+
.IP "" 4
|
699
|
+
.
|
700
|
+
.nf
|
701
|
+
|
702
|
+
after\-context: 1
|
703
|
+
before\-context: 6
|
704
|
+
context: 5
|
705
|
+
file\-color: blue on yellow
|
706
|
+
grep: true
|
707
|
+
highlight: off
|
708
|
+
ignore\-case: false
|
709
|
+
line\-number\-color: red
|
710
|
+
local\-config\-files: true
|
711
|
+
quiet: yes
|
712
|
+
text\-color\-0: f2331a on 2a3f44
|
713
|
+
text\-color\-1: bold underline red on 88a72d
|
714
|
+
text\-color\-2: a85387 on e4d3d2
|
715
|
+
verbose: false
|
716
|
+
.
|
717
|
+
.fi
|
718
|
+
.
|
719
|
+
.IP "" 0
|
720
|
+
.
|
721
|
+
.IP
|
722
|
+
"yes" and "on" are synonymnous with "true"\. "no" and "off" signify "false"\.
|
723
|
+
.
|
724
|
+
.IP
|
725
|
+
My ~/\.glarkrc file contains:
|
726
|
+
.
|
727
|
+
.IP "" 4
|
728
|
+
.
|
729
|
+
.nf
|
730
|
+
|
731
|
+
context: 3
|
732
|
+
quiet: true
|
733
|
+
local\-config\-files: true
|
734
|
+
.
|
735
|
+
.fi
|
736
|
+
.
|
737
|
+
.IP "" 0
|
738
|
+
|
739
|
+
.
|
740
|
+
.TP
|
741
|
+
\fB/path/\.\.\./\.glarkrc\fR
|
742
|
+
See the \fBlocal\-config\-files\fR field below\.
|
743
|
+
.
|
744
|
+
.SS "FIELDS"
|
745
|
+
.
|
746
|
+
.TP
|
747
|
+
\fBafter\-context\fR
|
748
|
+
See the \fB\-\-after\-context\fR option\. For example, for 3 lines of context after the match:
|
749
|
+
.
|
750
|
+
.IP "" 4
|
751
|
+
.
|
752
|
+
.nf
|
753
|
+
|
754
|
+
after\-context: 3
|
755
|
+
.
|
756
|
+
.fi
|
757
|
+
.
|
758
|
+
.IP "" 0
|
759
|
+
|
760
|
+
.
|
761
|
+
.TP
|
762
|
+
\fBbasename\fR
|
763
|
+
See the \fB\-\-basename\fR option\. For example, to omit Subversion directories:
|
764
|
+
.
|
765
|
+
.IP "" 4
|
766
|
+
.
|
767
|
+
.nf
|
768
|
+
|
769
|
+
basename: !/\e\.svn/
|
770
|
+
.
|
771
|
+
.fi
|
772
|
+
.
|
773
|
+
.IP "" 0
|
774
|
+
|
775
|
+
.
|
776
|
+
.TP
|
777
|
+
\fBbefore\-context\fR
|
778
|
+
See the \fB\-\-before\-context\fR option\. For example, for 7 lines of context before the match:
|
779
|
+
.
|
780
|
+
.IP "" 4
|
781
|
+
.
|
782
|
+
.nf
|
783
|
+
|
784
|
+
before\-context: 7
|
785
|
+
.
|
786
|
+
.fi
|
787
|
+
.
|
788
|
+
.IP "" 0
|
789
|
+
|
790
|
+
.
|
791
|
+
.TP
|
792
|
+
\fBbinary\-files\fR
|
793
|
+
See the \fB\-\-binary\-files\fR option\. For example, to always search binary files, instead of the default behavior of skipping them:
|
794
|
+
.
|
795
|
+
.IP "" 4
|
796
|
+
.
|
797
|
+
.nf
|
798
|
+
|
799
|
+
binary\-files: binary
|
800
|
+
.
|
801
|
+
.fi
|
802
|
+
.
|
803
|
+
.IP "" 0
|
804
|
+
|
805
|
+
.
|
806
|
+
.TP
|
807
|
+
\fBcontext\fR
|
808
|
+
See the \fB\-\-context\fR option\. For example, for 2 lines before and after matches:
|
809
|
+
.
|
810
|
+
.IP "" 4
|
811
|
+
.
|
812
|
+
.nf
|
813
|
+
|
814
|
+
context: 2
|
815
|
+
.
|
816
|
+
.fi
|
817
|
+
.
|
818
|
+
.IP "" 0
|
819
|
+
|
820
|
+
.
|
821
|
+
.TP
|
822
|
+
\fBexpression\fR
|
823
|
+
See the \fBEXPRESSION\fR section\. Example:
|
824
|
+
.
|
825
|
+
.IP "" 4
|
826
|
+
.
|
827
|
+
.nf
|
828
|
+
|
829
|
+
expression: \-\-or \'^\es*public\es+class\es+\ew+\' \'^\es*\ew+\e(
|
830
|
+
.
|
831
|
+
.fi
|
832
|
+
.
|
833
|
+
.IP "" 0
|
834
|
+
|
835
|
+
.
|
836
|
+
.TP
|
837
|
+
\fBfile\-color\fR
|
838
|
+
See the \fB\-\-file\-color\fR option\. For example, for white on black:
|
839
|
+
.
|
840
|
+
.IP "" 4
|
841
|
+
.
|
842
|
+
.nf
|
843
|
+
|
844
|
+
file\-color: white on black
|
845
|
+
.
|
846
|
+
.fi
|
847
|
+
.
|
848
|
+
.IP "" 0
|
849
|
+
|
850
|
+
.
|
851
|
+
.TP
|
852
|
+
\fBgrep\fR
|
853
|
+
See the \fB\-\-grep\fR option\. For example, to always run in grep mode:
|
854
|
+
.
|
855
|
+
.IP "" 4
|
856
|
+
.
|
857
|
+
.nf
|
858
|
+
|
859
|
+
grep: true
|
860
|
+
.
|
861
|
+
.fi
|
862
|
+
.
|
863
|
+
.IP "" 0
|
864
|
+
|
865
|
+
.
|
866
|
+
.TP
|
867
|
+
\fBhighlight\fR
|
868
|
+
See the \fB\-\-highlight\fR option\. To turn off highlighting:
|
869
|
+
.
|
870
|
+
.IP "" 4
|
871
|
+
.
|
872
|
+
.nf
|
873
|
+
|
874
|
+
highlight: false
|
875
|
+
.
|
876
|
+
.fi
|
877
|
+
.
|
878
|
+
.IP "" 0
|
879
|
+
|
880
|
+
.
|
881
|
+
.TP
|
882
|
+
\fBignore\-case\fR
|
883
|
+
See the \fB\-\-ignore\-case\fR option\. To make matching case\-insensitive:
|
884
|
+
.
|
885
|
+
.IP "" 4
|
886
|
+
.
|
887
|
+
.nf
|
888
|
+
|
889
|
+
ignore\-case: true
|
890
|
+
.
|
891
|
+
.fi
|
892
|
+
.
|
893
|
+
.IP "" 0
|
894
|
+
|
895
|
+
.
|
896
|
+
.TP
|
897
|
+
\fBknown\-nontext\-files\fR
|
898
|
+
The extensions of files that should be considered to always be nontext (binary)\. If a file extension is not known, the file contents are examined for nontext characters\. Thus, setting this field can result in faster searches\. Example:
|
899
|
+
.
|
900
|
+
.IP "" 4
|
901
|
+
.
|
902
|
+
.nf
|
903
|
+
|
904
|
+
known\-nontext\-files: class exe dll com
|
905
|
+
.
|
906
|
+
.fi
|
907
|
+
.
|
908
|
+
.IP "" 0
|
909
|
+
.
|
910
|
+
.IP
|
911
|
+
See the \fBExclusion of Non\-Text Files\fR section in \fBNOTES\fR for the default settings\.
|
912
|
+
.
|
913
|
+
.TP
|
914
|
+
\fBknown\-text\-files\fR
|
915
|
+
The extensions of files that should be considered to always be text\. See above for more\. Example:
|
916
|
+
.
|
917
|
+
.IP "" 4
|
918
|
+
.
|
919
|
+
.nf
|
920
|
+
|
921
|
+
known\-text\-files: ini bat xsl xml
|
922
|
+
.
|
923
|
+
.fi
|
924
|
+
.
|
925
|
+
.IP "" 0
|
926
|
+
.
|
927
|
+
.IP
|
928
|
+
See the \fBExclusion of Non\-Text Files\fR section in \fBNOTES\fR for the default settings\.
|
929
|
+
.
|
930
|
+
.TP
|
931
|
+
\fBlocal\-config\-files\fR
|
932
|
+
By default, glark uses only the configuration file ~/\.glarkrc\. Enabling this makes glark search upward from the current directory for the first \.glarkrc file\.
|
933
|
+
.
|
934
|
+
.IP
|
935
|
+
This can be used, for example, in a Java project, where \.class files are binary, versus a PHP project, where \.class files are text:
|
936
|
+
.
|
937
|
+
.IP "" 4
|
938
|
+
.
|
939
|
+
.nf
|
940
|
+
|
941
|
+
~/\.glarkrc
|
942
|
+
|
943
|
+
local\-config\-files: true
|
944
|
+
|
945
|
+
/projects/javaproj/\.glarkrc
|
946
|
+
|
947
|
+
known\-nontext\-files: class
|
948
|
+
|
949
|
+
/projects/phpproj/\.glarkrc
|
950
|
+
|
951
|
+
known\-text\-files: class
|
952
|
+
.
|
953
|
+
.fi
|
954
|
+
.
|
955
|
+
.IP "" 0
|
956
|
+
.
|
957
|
+
.IP
|
958
|
+
With this configuration, \.class files will automatically be treated as binary file in Java projects, and \.class files will be treated as text\. This can speed up searches\.
|
959
|
+
.
|
960
|
+
.IP
|
961
|
+
The configuration file ~/\.glarkrc is read first, so the definitions in the local configuration file will override those settings\.
|
962
|
+
.
|
963
|
+
.TP
|
964
|
+
\fBmatch\-name\fR, \fBskip\-name\fR, \fBmatch\-path\fR, \fBskip\-path\fR, \fBmatch\-ext\fR, \fBskip\-ext\fR, \fBmatch\-dirname\fR, \fBskip\-dirname\fR, \fBmatch\-dirpath\fR, \fBskip\-dirpath\fR
|
965
|
+
See the equivalent options\. For example, to omit files under CVS directories:
|
966
|
+
.
|
967
|
+
.IP "" 4
|
968
|
+
.
|
969
|
+
.nf
|
970
|
+
|
971
|
+
skip\-dirname: CVS
|
972
|
+
.
|
973
|
+
.fi
|
974
|
+
.
|
975
|
+
.IP "" 0
|
976
|
+
.
|
977
|
+
.IP
|
978
|
+
These fields can be specified multiple times\.
|
979
|
+
.
|
980
|
+
.TP
|
981
|
+
\fBquiet\fR
|
982
|
+
See the \fB\-\-quiet\fR option\.
|
983
|
+
.
|
984
|
+
.TP
|
985
|
+
\fBtext\-color\fR
|
986
|
+
See the \fB\-\-text\-color\fR option\. All matching regexps will be highlighted with the given color\. Example:
|
987
|
+
.
|
988
|
+
.IP "" 4
|
989
|
+
.
|
990
|
+
.nf
|
991
|
+
|
992
|
+
text\-color: bold blue on white
|
993
|
+
.
|
994
|
+
.fi
|
995
|
+
.
|
996
|
+
.IP "" 0
|
997
|
+
|
998
|
+
.
|
999
|
+
.TP
|
1000
|
+
\fBtext\-color\-NUM\fR
|
1001
|
+
Sets the color with which the NUMth regexp will be highlighted, for matching with multiple regular expressions, such as with the \fB\-\-or\fR or \fB\-\-file\fR option\. Example:
|
1002
|
+
.
|
1003
|
+
.IP "" 4
|
1004
|
+
.
|
1005
|
+
.nf
|
1006
|
+
|
1007
|
+
text\-color\-2: white on green
|
1008
|
+
.
|
1009
|
+
.fi
|
1010
|
+
.
|
1011
|
+
.IP "" 0
|
1012
|
+
|
1013
|
+
.
|
1014
|
+
.TP
|
1015
|
+
\fBverbose\fR
|
1016
|
+
See the \fB\-\-verbose\fR option\. Example:
|
1017
|
+
.
|
1018
|
+
.IP "" 4
|
1019
|
+
.
|
1020
|
+
.nf
|
1021
|
+
|
1022
|
+
verbose: true
|
1023
|
+
.
|
1024
|
+
.fi
|
1025
|
+
.
|
1026
|
+
.IP "" 0
|
1027
|
+
|
1028
|
+
.
|
1029
|
+
.SH "EXCLUSION OF NON\-TEXT FILES"
|
1030
|
+
Non\-text files are automatically skipped, by taking a sample of the file and checking for an excessive number of non\-ASCII characters\. This test is skipped for files with suffixes associated with text files:
|
1031
|
+
.
|
1032
|
+
.IP "" 4
|
1033
|
+
.
|
1034
|
+
.nf
|
1035
|
+
|
1036
|
+
c
|
1037
|
+
cpp
|
1038
|
+
css
|
1039
|
+
f
|
1040
|
+
for
|
1041
|
+
fpp
|
1042
|
+
h
|
1043
|
+
hpp
|
1044
|
+
html
|
1045
|
+
java
|
1046
|
+
mk
|
1047
|
+
php
|
1048
|
+
pl
|
1049
|
+
pm
|
1050
|
+
rb
|
1051
|
+
rbw
|
1052
|
+
txt
|
1053
|
+
.
|
1054
|
+
.fi
|
1055
|
+
.
|
1056
|
+
.IP "" 0
|
1057
|
+
.
|
1058
|
+
.P
|
1059
|
+
This test is also skipped for files with suffixes associated with non\-text (binary) files:
|
1060
|
+
.
|
1061
|
+
.IP "" 4
|
1062
|
+
.
|
1063
|
+
.nf
|
1064
|
+
|
1065
|
+
Z
|
1066
|
+
a
|
1067
|
+
bz2
|
1068
|
+
elc
|
1069
|
+
gif
|
1070
|
+
gz
|
1071
|
+
jar
|
1072
|
+
jpeg
|
1073
|
+
jpg
|
1074
|
+
o
|
1075
|
+
obj
|
1076
|
+
pdf
|
1077
|
+
png
|
1078
|
+
ps
|
1079
|
+
tar
|
1080
|
+
zip
|
1081
|
+
.
|
1082
|
+
.fi
|
1083
|
+
.
|
1084
|
+
.IP "" 0
|
1085
|
+
.
|
1086
|
+
.P
|
1087
|
+
See the \fBknown\-text\-files\fR and \fBknown\-nontext\-files\fR fields for denoting file name suffixes to associate as text or nontext\.
|
1088
|
+
.
|
1089
|
+
.SH "EXCLUSION OF DIRECTORIES"
|
1090
|
+
The \.svn and \.git directories are always excluded from recursive searching of a file hierarchy\.
|
1091
|
+
.
|
1092
|
+
.SH "EXIT STATUS"
|
1093
|
+
The exit status is 0 if matches were found; 1 if no matches were found, and 2 if there was an error\. An inverted match (the \-v/\-\-invert\-match option) will result in 1 for matches found, 0 for none found\.
|
1094
|
+
.
|
1095
|
+
.SH "SEE ALSO"
|
1096
|
+
For regular expressions, the \fBperlre\fR man page\.
|
1097
|
+
.
|
1098
|
+
.P
|
1099
|
+
Mastering Regular Expressions, by Jeffrey Friedl, published by O\'Reilly\.
|
1100
|
+
.
|
1101
|
+
.SH "CAVEATS"
|
1102
|
+
"Unbalanced" leading and trailing slashes will result in those slashes being included as characters in the regular expression\. Thus, the following pairs are equivalent:
|
1103
|
+
.
|
1104
|
+
.IP "" 4
|
1105
|
+
.
|
1106
|
+
.nf
|
1107
|
+
|
1108
|
+
/foo "/foo"
|
1109
|
+
/foo\e/ "/foo/"
|
1110
|
+
/foo\e/i "/foo/i"
|
1111
|
+
foo/ "foo/"
|
1112
|
+
foo/ "foo/"
|
1113
|
+
.
|
1114
|
+
.fi
|
1115
|
+
.
|
1116
|
+
.IP "" 0
|
1117
|
+
.
|
1118
|
+
.P
|
1119
|
+
The code to detect nontext files assumes ASCII, not Unicode\.
|
1120
|
+
.
|
1121
|
+
.SH "AUTHOR"
|
1122
|
+
Jeff Pace (jeugenepace at gmail dot com)
|
1123
|
+
.
|
1124
|
+
.P
|
1125
|
+
http://www\.incava\.org/projects/glark
|
1126
|
+
.
|
1127
|
+
.P
|
1128
|
+
http://www\.github\.com/jeugenepace/glark
|
1129
|
+
.
|
1130
|
+
.SH "COPYRIGHT"
|
1131
|
+
Copyright (c) 2006, Jeff Pace\.
|
1132
|
+
.
|
1133
|
+
.P
|
1134
|
+
All Rights Reserved\. This module is free software\. It may be used, redistributed and/or modified under the terms of the Lesser GNU Public License\. See http://www\.gnu\.org/licenses/lgpl\.html for more information\.
|