mh_xstrdup arguments now const
[mmh] / man / pick.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH PICK %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 pick \- select messages by content
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B pick
11 .RI [ +folder ]
12 .RI [ msgs ]
13 .RB [ \-and
14 \&...]
15 .RB [ \-or
16 \&...]
17 .RB [ \-not
18 \&...]
19 .RB [ \-lbrace
20 \&...
21 .BR \-rbrace ]
22 .RB [ \-\|\-component
23 .IR pattern ]
24 .RB [ \-cc
25 .IR pattern ]
26 .RB [ \-date
27 .IR pattern ]
28 .RB [ \-from
29 .IR pattern ]
30 .RB [ \-search
31 .IR pattern ]
32 .RB [ \-subject
33 .IR pattern ]
34 .RB [ \-to
35 .IR pattern ]
36 .RB [ \-after
37 .IR date ]
38 .RB [ \-before
39 .IR date ]
40 .RB [ \-datefield
41 .IR field ]
42 .RB [ \-format
43 .IR formatfile ]
44 .RB [ \-width
45 .IR columns ]
46 .RB [ \-sequence
47 .I name
48 \&...]
49 .RB [ \-public " | " \-nopublic ]
50 .RB [ \-zero " | " \-nozero ]
51 .RB [ \-list " | " \-nolist ]
52 .RB [ \-Version ]
53 .RB [ \-help ]
54 .ad
55 .PP
56 typical usage:
57 .PP
58 .RS 5
59 .nf
60 scan\0`pick\0\-from\0jones`
61 pick\0\-to\0holloway\0\-sequence\0select
62 show\0`pick\0\-before\0friday`
63 .fi
64 .RE
65 .ad
66 .SH DESCRIPTION
67 .B Pick
68 searches within a folder for messages with the specified
69 contents, and then identifies those messages.  Two types of search
70 primitives are available: pattern matching and date constraint
71 operations.
72 .PP
73 A modified
74 .BR grep (1)
75 is used to perform the matching, so the
76 full regular expression (see
77 .BR ed (1))
78 facility is available
79 within
80 .IR pattern .
81 With
82 .BR \-search ,
83 .I pattern
84 is used directly, and with the others, the grep pattern constructed is:
85 .PP
86 .RS 5
87 `component[ \\t]*:\&.*pattern'
88 .RE
89 .PP
90 This means that the pattern specified for a
91 .B \-search
92 will be found
93 everywhere in the message, including the header and the body, while
94 the other pattern matching requests are limited to the single specified
95 component.  The expression
96 .PP
97 .RS 5
98 `\-\|\-component\ pattern'
99 .RE
100 .PP
101 is a shorthand for specifying
102 .PP
103 .RS 5
104 `\-search `component[ \\t]*:\&.*pattern'\ '
105 .RE
106 .PP
107 It is used to pick a component which is not one of `To:',
108 `Cc:', `Date:', `From:', or `Subject:'.
109 An example is
110 .RB ` "pick\0\-\|\-reply\-to\0pooh" '.
111 .PP
112 Pattern matching is performed on a per\-line basis.  Within the header
113 of the message, each component is treated as one long line, but in the
114 body, each line is separate.  Lower\-case letters in the search pattern
115 will match either lower or upper case in the message, while upper case
116 will match only upper case.
117 .PP
118 Note that since the
119 .B \-date
120 switch is a pattern matching operation (as
121 described above), to find messages sent on a certain date the pattern
122 string must match the text of the `Date:' field of the message.
123 .PP
124 Independent of any pattern matching operations requested, the switches
125 .B \-after
126 .I date
127 or
128 .B \-before
129 .I date
130 may also be used to introduce date/time
131 constraints on all of the messages.  By default, the `Date:'
132 field is consulted, but if another date yielding field (such as
133 `BB\-Posted:' or `Delivery\-Date:') should be used, the
134 .B \-datefield
135 .I field
136 switch may be used.
137 .PP
138 With
139 .B \-before
140 and
141 .BR \-after ,
142 .B pick
143 will actually parse the date
144 fields in each of the messages specified in `msgs' and compare them
145 to the date/time specified.  If
146 .B \-after
147 is given, then only those
148 messages whose `Date:' field value is chronologically after the
149 date specified will be considered.  The
150 .B \-before
151 switch specifies the
152 complimentary action.
153 .PP
154 Both the
155 .B \-after
156 and
157 .B \-before
158 switches take legal 822\-style date
159 specifications as arguments.
160 .B Pick
161 will default certain missing
162 fields so that the entire date need not be specified.  These fields
163 are (in order of defaulting): timezone, time and timezone, date, date
164 and timezone.  All defaults are taken from the current date, time,
165 and timezone.
166 .PP
167 In addition to 822\-style dates,
168 .B pick
169 will also recognize any of
170 the days of the week (`sunday', `monday', and so on),
171 and the special dates `today', `yesterday' (24 hours
172 ago), and `tomorrow' (24 hours from now).  All days of the
173 week are judged to refer to a day in the past (e.g., telling \fIpick\fR
174 `saturday' on a `tuesday' means `last\ saturday'
175 not `this\ saturday').
176 Further more, dates in a simplified ISO 8601/RFC 3339 style (e.g.
177 `YYYY-MM-DD' or `YYYY-MM-DD hh:mm:ss') are accepted.
178 Finally, in addition to these special specifications,
179 .B pick
180 will
181 also honor a date specification of the form `\-\fIddd\fR', which means
182 `\fIddd\fR days ago'.
183 For example,
184 .PP
185 .RS 5
186 .nf
187 pick\0\-after\0\-30
188 .fi
189 .RE
190 .PP
191 identifies the messages of the last thirty days.
192 .PP
193 .B Pick
194 supports complex boolean operations on the searching primitives
195 with the
196 .BR \-and ,
197 .BR \-or ,
198 .BR \-not ,
199 and
200 .B \-lbrace
201 .B \&...
202 .B \-rbrace
203 switches.
204 For example,
205 .PP
206 .RS 5
207 .nf
208 pick\0\-after\0yesterday\0\-and
209      \-lbrace\0\-from\0freida\0\-or\0\-from\0fear\0\-rbrace
210 .fi
211 .RE
212 .PP
213 identifies messages recently sent by `frieda' or `fear'.
214 .PP
215 The matching primitives take precedence over the
216 .B \-not
217 switch, which in turn takes precedence over
218 .B \-and
219 which in turn takes precedence
220 over
221 .BR \-or .
222 To override the default precedence, the
223 .B \-lbrace
224 and
225 .B \-rbrace
226 switches are provided, which act just like opening and closing
227 parentheses in logical expressions.
228 .PP
229 If no search criteria are given, all the messages specified on the
230 command line are selected (this defaults to `all').
231 .PP
232 Once the search has been performed, if the
233 .B \-list
234 switch is given, the
235 message numbers of the selected messages are written to the standard
236 output separated by newlines.  This is
237 .B extremely
238 useful for
239 quickly generating arguments for other
240 .B mmh
241 programs by using the
242 `backquoting' syntax of the shell.  For example, the command
243 .PP
244 .RS 5
245 scan\0`pick\0+todo\0\-after\0`31 Mar 83 0123 PST'`
246 .RE
247 .PP
248 says to
249 .B scan
250 those messages in the indicated folder which meet the
251 appropriate criterion.  Note that since
252 .BR pick 's
253 context changes
254 are written out prior to
255 .BR scan 's
256 invocation, you need not give
257 the folder argument to
258 .B scan
259 as well.
260 .PP
261 The
262 .B \-sequence
263 .I name
264 switch may be given once for each sequence the user wishes to define.
265 For each sequence named, that sequence will be defined to mean exactly
266 those messages selected by
267 .BR pick .
268 For example,
269 .PP
270 .RS 5
271 pick\0\-from\0frated\0\-seq\0fred
272 .RE
273 .PP
274 defines a new message sequence for the current folder called
275 `fred' which contains exactly those messages that were selected.
276 .PP
277 By default,
278 .B pick
279 will zero the sequence before adding it.  This
280 action can be disabled with the
281 .B \-nozero
282 switch, which means that the
283 messages selected by
284 .B pick
285 will be added to the sequence, if it
286 already exists, and any messages already a part of that sequence will
287 remain so.
288 .PP
289 The
290 .B \-public
291 and
292 .B \-nopublic
293 switches are used by
294 .B pick
295 in the
296 same way
297 .B mark
298 uses them.
299
300 .SH FILES
301 .fc ^ ~
302 .nf
303 .ta \w'%etcdir%/ExtraBigFileName  'u
304 ^$HOME/.mmh/profile~^The user profile
305 .fi
306
307 .SH "PROFILE COMPONENTS"
308 .fc ^ ~
309 .nf
310 .ta 2.4i
311 .ta \w'ExtraBigProfileName  'u
312 ^Path:~^To determine the user's mail storage
313 ^Current\-Folder:~^To find the default current folder
314 .fi
315
316 .SH "SEE ALSO"
317 mark(1)
318
319 .SH DEFAULTS
320 .nf
321 .RB ` +folder "' defaults to the current folder"
322 .RB ` msgs "' defaults to all"
323 .RB ` "\-datefield date" '
324 .RB ` \-zero '
325 .RB ` \-list "' is the default if no `\-sequence', `\-nolist' otherwise"
326 .fi
327
328 .SH CONTEXT
329 If a folder is given, it will become the current folder.
330
331 .SH HISTORY
332 In previous versions of
333 .BR MH ,
334 the
335 .B pick
336 command would
337 .BR show ,
338 .BR scan ,
339 or
340 .B refile
341 the selected messages.  This was rather
342 `inverted logic' from the UNIX point of view, so
343 .B pick
344 was changed to define sequences and output those sequences.  Hence,
345 .B pick
346 can be used to generate the arguments for all other
347 .B MH
348 commands, instead of giving
349 .B pick
350 endless switches for invoking those commands
351 itself.
352 .PP
353 Also, previous versions of
354 .B pick
355 balked if you didn't specify
356 a search string or a date/time constraint.  The current version does
357 not, and merely matches the messages you specify.  This lets you type
358 something like:
359 .PP
360 .RS 5
361 show\0`pick\0l:20\0\-seq\0fear`
362 .RE
363 .PP
364 instead of typing
365 .PP
366 .RS 5
367 .nf
368 mark\0\-add\0\-nozero\0\-seq\0fear\0l:20
369 show\0fear
370 .fi
371 .RE
372 .PP
373 Finally, timezones used to be ignored when comparing dates: they aren't
374 any more.
375
376 .SH "HELPFUL HINTS"
377 Use
378 .RB ` "pick sequence \-list" '
379 to enumerate the messages in a sequence
380 (such as for use by a shell script).
381
382 .SH BUGS
383 Any occurrence of
384 .B \-datefield
385 must occur prior to the
386 .B \-after
387 or
388 .B \-before
389 switch it applies to.
390 .PP
391 If
392 .B pick
393 is used in a back\-quoted operation, such as
394 .PP
395 .RS 5
396 scan\0`pick\0\-from\0jones`
397 .RE
398 .PP
399 and
400 .B pick
401 selects no messages (e.g., no messages are from
402 `jones'), then the shell will still run the outer command (e.g.,
403 .BR scan ).
404 Since no messages were matched,
405 .B pick
406 produced
407 no output, and the argument given to the outer command as a result of
408 backquoting
409 .B pick
410 is empty.  In the case of
411 .B mmh
412 programs,
413 the outer command now acts as if the default `msg' or `msgs' should be
414 used (e.g., `all' in the case of
415 .BR scan ).
416 To prevent this
417 unexpected behavior, if
418 .B \-list
419 was given, and if its standard output is not a tty, then
420 .B pick
421 outputs the illegal message number `0'
422 when it fails.  This lets the outer command fail gracefully as well.
423 .PP
424 The pattern syntax `[l-r]' is not supported; each letter to be
425 matched must be included within the square brackets.