Commit | Line | Data |
---|---|---|
9255ee31 EZ |
1 | .\" |
2 | .\" MAN PAGE COMMENTS to | |
3 | .\" | |
4 | .\" Chet Ramey | |
5 | .\" Information Network Services | |
6 | .\" Case Western Reserve University | |
775e241e | 7 | .\" chet.ramey@case.edu |
9255ee31 | 8 | .\" |
cb41b9e7 | 9 | .\" Last Change: Sun Oct 8 11:43:43 EDT 2017 |
9255ee31 | 10 | .\" |
cb41b9e7 | 11 | .TH HISTORY 3 "2017 October 8" "GNU History 6.3" |
9255ee31 EZ |
12 | .\" |
13 | .\" File Name macro. This used to be `.PN', for Path Name, | |
14 | .\" but Sun doesn't seem to like that very much. | |
15 | .\" | |
16 | .de FN | |
17 | \fI\|\\$1\|\fP | |
18 | .. | |
19 | .ds lp \fR\|(\fP | |
20 | .ds rp \fR\|)\fP | |
21 | .\" FnN return-value fun-name N arguments | |
22 | .de Fn1 | |
23 | \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp | |
24 | .br | |
25 | .. | |
26 | .de Fn2 | |
27 | .if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp | |
28 | .if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp | |
29 | .br | |
30 | .. | |
31 | .de Fn3 | |
32 | .if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp | |
33 | .if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp | |
34 | .br | |
35 | .. | |
36 | .de Vb | |
37 | \fI\\$1\fP \fB\\$2\fP | |
38 | .br | |
39 | .. | |
40 | .SH NAME | |
41 | history \- GNU History Library | |
42 | .SH COPYRIGHT | |
cb41b9e7 TT |
43 | .if t The GNU History Library is Copyright \(co 1989-2017 by the Free Software Foundation, Inc. |
44 | .if n The GNU History Library is Copyright (C) 1989-2017 by the Free Software Foundation, Inc. | |
9255ee31 EZ |
45 | .SH DESCRIPTION |
46 | Many programs read input from the user a line at a time. The GNU | |
47 | History library is able to keep track of those lines, associate arbitrary | |
48 | data with each line, and utilize information from previous lines in | |
49 | composing new ones. | |
50 | .PP | |
51 | .SH "HISTORY EXPANSION" | |
52 | .PP | |
53 | The history library supports a history expansion feature that | |
54 | is identical to the history expansion in | |
55 | .BR bash. | |
56 | This section describes what syntax features are available. | |
57 | .PP | |
58 | History expansions introduce words from the history list into | |
59 | the input stream, making it easy to repeat commands, insert the | |
60 | arguments to a previous command into the current input line, or | |
61 | fix errors in previous commands quickly. | |
62 | .PP | |
63 | History expansion is usually performed immediately after a complete line | |
64 | is read. | |
65 | It takes place in two parts. | |
66 | The first is to determine which line from the history list | |
67 | to use during substitution. | |
68 | The second is to select portions of that line for inclusion into | |
69 | the current one. | |
70 | The line selected from the history is the \fIevent\fP, | |
71 | and the portions of that line that are acted upon are \fIwords\fP. | |
72 | Various \fImodifiers\fP are available to manipulate the selected words. | |
73 | The line is broken into words in the same fashion as \fBbash\fP | |
74 | does when reading input, | |
75 | so that several words that would otherwise be separated | |
76 | are considered one word when surrounded by quotes (see the | |
77 | description of \fBhistory_tokenize()\fP below). | |
78 | History expansions are introduced by the appearance of the | |
79 | history expansion character, which is \^\fB!\fP\^ by default. | |
80 | Only backslash (\^\fB\e\fP\^) and single quotes can quote | |
81 | the history expansion character. | |
82 | .SS Event Designators | |
83 | .PP | |
84 | An event designator is a reference to a command line entry in the | |
85 | history list. | |
cc88a640 JK |
86 | Unless the reference is absolute, events are relative to the current |
87 | position in the history list. | |
9255ee31 EZ |
88 | .PP |
89 | .PD 0 | |
90 | .TP | |
91 | .B ! | |
92 | Start a history substitution, except when followed by a | |
93 | .BR blank , | |
94 | newline, = or (. | |
95 | .TP | |
96 | .B !\fIn\fR | |
97 | Refer to command line | |
98 | .IR n . | |
99 | .TP | |
100 | .B !\-\fIn\fR | |
cc88a640 | 101 | Refer to the current command minus |
9255ee31 EZ |
102 | .IR n . |
103 | .TP | |
104 | .B !! | |
105 | Refer to the previous command. This is a synonym for `!\-1'. | |
106 | .TP | |
107 | .B !\fIstring\fR | |
cc88a640 JK |
108 | Refer to the most recent command |
109 | preceding the current position in the history list | |
110 | starting with | |
9255ee31 EZ |
111 | .IR string . |
112 | .TP | |
113 | .B !?\fIstring\fR\fB[?]\fR | |
cc88a640 | 114 | Refer to the most recent command |
775e241e | 115 | preceding the current position in the history list |
cc88a640 | 116 | containing |
9255ee31 EZ |
117 | .IR string . |
118 | The trailing \fB?\fP may be omitted if | |
119 | .I string | |
120 | is followed immediately by a newline. | |
121 | .TP | |
122 | .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u | |
123 | Quick substitution. Repeat the last command, replacing | |
124 | .I string1 | |
125 | with | |
126 | .IR string2 . | |
127 | Equivalent to | |
128 | ``!!:s/\fIstring1\fP/\fIstring2\fP/'' | |
129 | (see \fBModifiers\fP below). | |
130 | .TP | |
131 | .B !# | |
132 | The entire command line typed so far. | |
133 | .PD | |
134 | .SS Word Designators | |
135 | .PP | |
136 | Word designators are used to select desired words from the event. | |
775e241e | 137 | A |
9255ee31 EZ |
138 | .B : |
139 | separates the event specification from the word designator. | |
140 | It may be omitted if the word designator begins with a | |
141 | .BR ^ , | |
142 | .BR $ , | |
143 | .BR * , | |
144 | .BR \- , | |
145 | or | |
146 | .BR % . | |
147 | Words are numbered from the beginning of the line, | |
148 | with the first word being denoted by 0 (zero). | |
149 | Words are inserted into the current line separated by single spaces. | |
150 | .PP | |
151 | .PD 0 | |
152 | .TP | |
153 | .B 0 (zero) | |
154 | The zeroth word. For the shell, this is the command | |
155 | word. | |
156 | .TP | |
157 | .I n | |
158 | The \fIn\fRth word. | |
159 | .TP | |
160 | .B ^ | |
161 | The first argument. That is, word 1. | |
162 | .TP | |
163 | .B $ | |
775e241e TT |
164 | The last word. This is usually the last argument, but will expand to the |
165 | zeroth word if there is only one word in the line. | |
9255ee31 EZ |
166 | .TP |
167 | .B % | |
168 | The word matched by the most recent `?\fIstring\fR?' search. | |
169 | .TP | |
170 | .I x\fB\-\fPy | |
171 | A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. | |
172 | .TP | |
173 | .B * | |
174 | All of the words but the zeroth. This is a synonym | |
175 | for `\fI1\-$\fP'. It is not an error to use | |
176 | .B * | |
177 | if there is just one | |
178 | word in the event; the empty string is returned in that case. | |
179 | .TP | |
180 | .B x* | |
181 | Abbreviates \fIx\-$\fP. | |
182 | .TP | |
183 | .B x\- | |
184 | Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word. | |
185 | .PD | |
186 | .PP | |
187 | If a word designator is supplied without an event specification, the | |
188 | previous command is used as the event. | |
189 | .SS Modifiers | |
190 | .PP | |
191 | After the optional word designator, there may appear a sequence of | |
192 | one or more of the following modifiers, each preceded by a `:'. | |
193 | .PP | |
194 | .PD 0 | |
195 | .PP | |
196 | .TP | |
197 | .B h | |
198 | Remove a trailing file name component, leaving only the head. | |
199 | .TP | |
200 | .B t | |
201 | Remove all leading file name components, leaving the tail. | |
202 | .TP | |
203 | .B r | |
204 | Remove a trailing suffix of the form \fI.xxx\fP, leaving the | |
205 | basename. | |
206 | .TP | |
207 | .B e | |
208 | Remove all but the trailing suffix. | |
209 | .TP | |
210 | .B p | |
211 | Print the new command but do not execute it. | |
212 | .TP | |
213 | .B q | |
214 | Quote the substituted words, escaping further substitutions. | |
215 | .TP | |
216 | .B x | |
217 | Quote the substituted words as with | |
218 | .BR q , | |
219 | but break into words at | |
220 | .B blanks | |
221 | and newlines. | |
222 | .TP | |
223 | .B s/\fIold\fP/\fInew\fP/ | |
224 | Substitute | |
225 | .I new | |
226 | for the first occurrence of | |
227 | .I old | |
228 | in the event line. Any delimiter can be used in place of /. The | |
229 | final delimiter is optional if it is the last character of the | |
230 | event line. The delimiter may be quoted in | |
231 | .I old | |
232 | and | |
233 | .I new | |
234 | with a single backslash. If & appears in | |
235 | .IR new , | |
236 | it is replaced by | |
237 | .IR old . | |
238 | A single backslash will quote the &. If | |
239 | .I old | |
240 | is null, it is set to the last | |
241 | .I old | |
242 | substituted, or, if no previous history substitutions took place, | |
243 | the last | |
244 | .I string | |
245 | in a | |
246 | .B !?\fIstring\fR\fB[?]\fR | |
247 | search. | |
248 | .TP | |
249 | .B & | |
250 | Repeat the previous substitution. | |
251 | .TP | |
252 | .B g | |
253 | Cause changes to be applied over the entire event line. This is | |
254 | used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') | |
255 | or `\fB:&\fP'. If used with | |
256 | `\fB:s\fP', any delimiter can be used | |
257 | in place of /, and the final delimiter is optional | |
258 | if it is the last character of the event line. | |
5bdf8622 DJ |
259 | An \fBa\fP may be used as a synonym for \fBg\fP. |
260 | .TP | |
261 | .B G | |
262 | Apply the following `\fBs\fP' modifier once to each word in the event line. | |
9255ee31 EZ |
263 | .PD |
264 | .SH "PROGRAMMING WITH HISTORY FUNCTIONS" | |
265 | This section describes how to use the History library in other programs. | |
266 | .SS Introduction to History | |
267 | .PP | |
268 | The programmer using the History library has available functions | |
269 | for remembering lines on a history list, associating arbitrary data | |
270 | with a line, removing lines from the list, searching through the list | |
271 | for a line containing an arbitrary text string, and referencing any line | |
272 | in the list directly. In addition, a history \fIexpansion\fP function | |
273 | is available which provides for a consistent user interface across | |
274 | different programs. | |
275 | .PP | |
276 | The user using programs written with the History library has the | |
277 | benefit of a consistent user interface with a set of well-known | |
278 | commands for manipulating the text of previous lines and using that text | |
279 | in new commands. The basic history manipulation commands are | |
280 | identical to | |
281 | the history substitution provided by \fBbash\fP. | |
282 | .PP | |
283 | If the programmer desires, he can use the Readline library, which | |
284 | includes some history manipulation by default, and has the added | |
285 | advantage of command line editing. | |
286 | .PP | |
287 | Before declaring any functions using any functionality the History | |
288 | library provides in other code, an application writer should include | |
289 | the file | |
290 | .FN <readline/history.h> | |
291 | in any file that uses the | |
292 | History library's features. It supplies extern declarations for all | |
293 | of the library's public functions and variables, and declares all of | |
294 | the public data structures. | |
295 | ||
296 | .SS History Storage | |
297 | .PP | |
298 | The history list is an array of history entries. A history entry is | |
299 | declared as follows: | |
300 | .PP | |
301 | .Vb "typedef void *" histdata_t; | |
302 | .PP | |
303 | .nf | |
304 | typedef struct _hist_entry { | |
305 | char *line; | |
5bdf8622 | 306 | char *timestamp; |
9255ee31 EZ |
307 | histdata_t data; |
308 | } HIST_ENTRY; | |
309 | .fi | |
310 | .PP | |
311 | The history list itself might therefore be declared as | |
312 | .PP | |
313 | .Vb "HIST_ENTRY **" the_history_list; | |
314 | .PP | |
315 | The state of the History library is encapsulated into a single structure: | |
316 | .PP | |
317 | .nf | |
318 | /* | |
319 | * A structure used to pass around the current state of the history. | |
320 | */ | |
321 | typedef struct _hist_state { | |
322 | HIST_ENTRY **entries; /* Pointer to the entries themselves. */ | |
323 | int offset; /* The location pointer within this array. */ | |
324 | int length; /* Number of elements within this array. */ | |
325 | int size; /* Number of slots allocated to this array. */ | |
326 | int flags; | |
327 | } HISTORY_STATE; | |
328 | .fi | |
329 | .PP | |
330 | If the flags member includes \fBHS_STIFLED\fP, the history has been | |
331 | stifled. | |
332 | .SH "History Functions" | |
333 | .PP | |
334 | This section describes the calling sequence for the various functions | |
335 | exported by the GNU History library. | |
336 | .SS Initializing History and State Management | |
337 | This section describes functions used to initialize and manage | |
338 | the state of the History library when you want to use the history | |
339 | functions in your program. | |
340 | ||
341 | .Fn1 void using_history void | |
342 | Begin a session in which the history functions might be used. This | |
343 | initializes the interactive variables. | |
344 | ||
345 | .Fn1 "HISTORY_STATE *" history_get_history_state void | |
346 | Return a structure describing the current state of the input history. | |
347 | ||
348 | .Fn1 void history_set_history_state "HISTORY_STATE *state" | |
349 | Set the state of the history list according to \fIstate\fP. | |
350 | ||
351 | .SS History List Management | |
352 | ||
353 | These functions manage individual entries on the history list, or set | |
354 | parameters managing the list itself. | |
355 | ||
356 | .Fn1 void add_history "const char *string" | |
357 | Place \fIstring\fP at the end of the history list. The associated data | |
358 | field (if any) is set to \fBNULL\fP. | |
cb41b9e7 TT |
359 | If the maximum number of history entries has been set using |
360 | \fBstifle_history()\fP, and the new number of history entries would exceed | |
361 | that maximum, the oldest history entry is removed. | |
9255ee31 | 362 | |
5bdf8622 DJ |
363 | .Fn1 void add_history_time "const char *string" |
364 | Change the time stamp associated with the most recent history entry to | |
365 | \fIstring\fP. | |
366 | ||
9255ee31 EZ |
367 | .Fn1 "HIST_ENTRY *" remove_history "int which" |
368 | Remove history entry at offset \fIwhich\fP from the history. The | |
369 | removed element is returned so you can free the line, data, | |
370 | and containing structure. | |
371 | ||
5bdf8622 DJ |
372 | .Fn1 "histdata_t" free_history_entry "HIST_ENTRY *histent" |
373 | Free the history entry \fIhistent\fP and any history library private | |
374 | data associated with it. Returns the application-specific data | |
375 | so the caller can dispose of it. | |
376 | ||
9255ee31 EZ |
377 | .Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" "histdata_t data" |
378 | Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP. | |
5bdf8622 DJ |
379 | This returns the old entry so the caller can dispose of any |
380 | application-specific data. In the case | |
9255ee31 EZ |
381 | of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned. |
382 | ||
383 | .Fn1 void clear_history "void" | |
384 | Clear the history list by deleting all the entries. | |
385 | ||
386 | .Fn1 void stifle_history "int max" | |
387 | Stifle the history list, remembering only the last \fImax\fP entries. | |
cb41b9e7 | 388 | The history list will contain only \fImax\fP entries at a time. |
9255ee31 EZ |
389 | |
390 | .Fn1 int unstifle_history "void" | |
391 | Stop stifling the history. This returns the previously-set | |
392 | maximum number of history entries (as set by \fBstifle_history()\fP). | |
393 | history was stifled. The value is positive if the history was | |
394 | stifled, negative if it wasn't. | |
395 | ||
396 | .Fn1 int history_is_stifled "void" | |
397 | Returns non-zero if the history is stifled, zero if it is not. | |
398 | ||
399 | .SS Information About the History List | |
400 | ||
401 | These functions return information about the entire history list or | |
402 | individual list entries. | |
403 | ||
404 | .Fn1 "HIST_ENTRY **" history_list "void" | |
405 | Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the | |
406 | current input history. Element 0 of this list is the beginning of time. | |
407 | If there is no history, return \fBNULL\fP. | |
408 | ||
409 | .Fn1 int where_history "void" | |
410 | Returns the offset of the current history element. | |
411 | ||
412 | .Fn1 "HIST_ENTRY *" current_history "void" | |
413 | Return the history entry at the current position, as determined by | |
414 | \fBwhere_history()\fP. If there is no entry there, return a \fBNULL\fP | |
415 | pointer. | |
416 | ||
417 | .Fn1 "HIST_ENTRY *" history_get "int offset" | |
cb41b9e7 TT |
418 | Return the history entry at position \fIoffset\fP. |
419 | The range of valid values of \fIoffset\fP starts at \fBhistory_base\fP | |
420 | and ends at \fBhistory_length\fP \- 1. | |
421 | If there is no entry there, or if \fIoffset\fP is outside the valid | |
422 | range, return a \fBNULL\fP pointer. | |
9255ee31 | 423 | |
5bdf8622 DJ |
424 | .Fn1 "time_t" history_get_time "HIST_ENTRY *" |
425 | Return the time stamp associated with the history entry passed as the argument. | |
426 | ||
9255ee31 EZ |
427 | .Fn1 int history_total_bytes "void" |
428 | Return the number of bytes that the primary history entries are using. | |
429 | This function returns the sum of the lengths of all the lines in the | |
430 | history. | |
431 | ||
432 | .SS Moving Around the History List | |
433 | ||
434 | These functions allow the current index into the history list to be | |
435 | set or changed. | |
436 | ||
437 | .Fn1 int history_set_pos "int pos" | |
438 | Set the current history offset to \fIpos\fP, an absolute index | |
439 | into the list. | |
440 | Returns 1 on success, 0 if \fIpos\fP is less than zero or greater | |
441 | than the number of history entries. | |
442 | ||
443 | .Fn1 "HIST_ENTRY *" previous_history "void" | |
444 | Back up the current history offset to the previous history entry, and | |
445 | return a pointer to that entry. If there is no previous entry, return | |
446 | a \fBNULL\fP pointer. | |
447 | ||
448 | .Fn1 "HIST_ENTRY *" next_history "void" | |
775e241e TT |
449 | If the current history offset refers to a valid history entry, |
450 | increment the current history offset. | |
451 | If the possibly-incremented history offset refers to a valid history | |
452 | entry, return a pointer to that entry; | |
453 | otherwise, return a \fBNULL\fP pointer. | |
9255ee31 EZ |
454 | |
455 | .SS Searching the History List | |
456 | ||
457 | These functions allow searching of the history list for entries containing | |
458 | a specific string. Searching may be performed both forward and backward | |
459 | from the current history position. The search may be \fIanchored\fP, | |
460 | meaning that the string must match at the beginning of the history entry. | |
461 | ||
462 | .Fn2 int history_search "const char *string" "int direction" | |
463 | Search the history for \fIstring\fP, starting at the current history offset. | |
464 | If \fIdirection\fP is less than 0, then the search is through | |
465 | previous entries, otherwise through subsequent entries. | |
466 | If \fIstring\fP is found, then | |
467 | the current history index is set to that history entry, and the value | |
468 | returned is the offset in the line of the entry where | |
469 | \fIstring\fP was found. Otherwise, nothing is changed, and a -1 is | |
470 | returned. | |
471 | ||
472 | .Fn2 int history_search_prefix "const char *string" "int direction" | |
473 | Search the history for \fIstring\fP, starting at the current history | |
474 | offset. The search is anchored: matching lines must begin with | |
475 | \fIstring\fP. If \fIdirection\fP is less than 0, then the search is | |
476 | through previous entries, otherwise through subsequent entries. | |
477 | If \fIstring\fP is found, then the | |
478 | current history index is set to that entry, and the return value is 0. | |
479 | Otherwise, nothing is changed, and a -1 is returned. | |
480 | ||
481 | .Fn3 int history_search_pos "const char *string" "int direction" "int pos" | |
482 | Search for \fIstring\fP in the history list, starting at \fIpos\fP, an | |
483 | absolute index into the list. If \fIdirection\fP is negative, the search | |
484 | proceeds backward from \fIpos\fP, otherwise forward. Returns the absolute | |
485 | index of the history element where \fIstring\fP was found, or -1 otherwise. | |
486 | ||
487 | .SS Managing the History File | |
488 | The History library can read the history from and write it to a file. | |
489 | This section documents the functions for managing a history file. | |
490 | ||
491 | .Fn1 int read_history "const char *filename" | |
492 | Add the contents of \fIfilename\fP to the history list, a line at a time. | |
493 | If \fIfilename\fP is \fBNULL\fP, then read from \fI~/.history\fP. | |
494 | Returns 0 if successful, or \fBerrno\fP if not. | |
495 | ||
496 | .Fn3 int read_history_range "const char *filename" "int from" "int to" | |
497 | Read a range of lines from \fIfilename\fP, adding them to the history list. | |
498 | Start reading at line \fIfrom\fP and end at \fIto\fP. | |
499 | If \fIfrom\fP is zero, start at the beginning. If \fIto\fP is less than | |
500 | \fIfrom\fP, then read until the end of the file. If \fIfilename\fP is | |
501 | \fBNULL\fP, then read from \fI~/.history\fP. Returns 0 if successful, | |
502 | or \fBerrno\fP if not. | |
503 | ||
504 | .Fn1 int write_history "const char *filename" | |
505 | Write the current history to \fIfilename\fP, overwriting \fIfilename\fP | |
506 | if necessary. | |
507 | If \fIfilename\fP is \fBNULL\fP, then write the history list to \fI~/.history\fP. | |
508 | Returns 0 on success, or \fBerrno\fP on a read or write error. | |
509 | ||
510 | ||
511 | .Fn2 int append_history "int nelements" "const char *filename" | |
512 | Append the last \fInelements\fP of the history list to \fIfilename\fP. | |
513 | If \fIfilename\fP is \fBNULL\fP, then append to \fI~/.history\fP. | |
514 | Returns 0 on success, or \fBerrno\fP on a read or write error. | |
515 | ||
516 | .Fn2 int history_truncate_file "const char *filename" "int nlines" | |
517 | Truncate the history file \fIfilename\fP, leaving only the last | |
518 | \fInlines\fP lines. | |
519 | If \fIfilename\fP is \fBNULL\fP, then \fI~/.history\fP is truncated. | |
520 | Returns 0 on success, or \fBerrno\fP on failure. | |
521 | ||
522 | .SS History Expansion | |
523 | ||
524 | These functions implement history expansion. | |
525 | ||
526 | .Fn2 int history_expand "char *string" "char **output" | |
527 | Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer | |
528 | to a string. Returns: | |
529 | .RS | |
530 | .PD 0 | |
531 | .TP | |
532 | 0 | |
533 | If no expansions took place (or, if the only change in | |
534 | the text was the removal of escape characters preceding the history expansion | |
535 | character); | |
536 | .TP | |
537 | 1 | |
538 | if expansions did take place; | |
539 | .TP | |
540 | -1 | |
541 | if there was an error in expansion; | |
542 | .TP | |
543 | 2 | |
544 | if the returned line should be displayed, but not executed, | |
545 | as with the \fB:p\fP modifier. | |
546 | .PD | |
547 | .RE | |
548 | If an error ocurred in expansion, then \fIoutput\fP contains a descriptive | |
549 | error message. | |
550 | ||
551 | .Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar" | |
552 | Returns the text of the history event beginning at \fIstring\fP + | |
553 | \fI*cindex\fP. \fI*cindex\fP is modified to point to after the event | |
554 | specifier. At function entry, \fIcindex\fP points to the index into | |
555 | \fIstring\fP where the history event specification begins. \fIqchar\fP | |
556 | is a character that is allowed to end the event specification in addition | |
557 | to the ``normal'' terminating characters. | |
558 | ||
559 | .Fn1 "char **" history_tokenize "const char *string" | |
560 | Return an array of tokens parsed out of \fIstring\fP, much as the | |
561 | shell might. | |
562 | The tokens are split on the characters in the | |
563 | \fBhistory_word_delimiters\fP variable, | |
564 | and shell quoting conventions are obeyed. | |
565 | ||
566 | .Fn3 "char *" history_arg_extract "int first" "int last" "const char *string" | |
567 | Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP | |
568 | arguments present in \fIstring\fP. Arguments are split using | |
569 | \fBhistory_tokenize()\fP. | |
570 | ||
571 | .SS History Variables | |
572 | ||
573 | This section describes the externally-visible variables exported by | |
574 | the GNU History Library. | |
575 | ||
576 | .Vb int history_base | |
577 | The logical offset of the first entry in the history list. | |
578 | ||
579 | .Vb int history_length | |
580 | The number of entries currently stored in the history list. | |
581 | ||
582 | .Vb int history_max_entries | |
583 | The maximum number of history entries. This must be changed using | |
584 | \fBstifle_history()\fP. | |
585 | ||
cc88a640 | 586 | .Vb int history_wite_timestamps |
5bdf8622 DJ |
587 | If non-zero, timestamps are written to the history file, so they can be |
588 | preserved between sessions. The default value is 0, meaning that | |
589 | timestamps are not saved. | |
cc88a640 JK |
590 | The current timestamp format uses the value of \fIhistory_comment_char\fP |
591 | to delimit timestamp entries in the history file. If that variable does | |
592 | not have a value (the default), timestamps will not be written. | |
5bdf8622 | 593 | |
9255ee31 EZ |
594 | .Vb char history_expansion_char |
595 | The character that introduces a history event. The default is \fB!\fP. | |
596 | Setting this to 0 inhibits history expansion. | |
597 | ||
598 | .Vb char history_subst_char | |
599 | The character that invokes word substitution if found at the start of | |
600 | a line. The default is \fB^\fP. | |
601 | ||
602 | .Vb char history_comment_char | |
603 | During tokenization, if this character is seen as the first character | |
604 | of a word, then it and all subsequent characters up to a newline are | |
605 | ignored, suppressing history expansion for the remainder of the line. | |
606 | This is disabled by default. | |
607 | ||
608 | .Vb "char *" history_word_delimiters | |
609 | The characters that separate tokens for \fBhistory_tokenize()\fP. | |
610 | The default value is \fB"\ \et\en()<>;&|"\fP. | |
611 | ||
612 | .Vb "char *" history_no_expand_chars | |
613 | The list of characters which inhibit history expansion if found immediately | |
614 | following \fBhistory_expansion_char\fP. The default is space, tab, newline, | |
615 | \fB\er\fP, and \fB=\fP. | |
616 | ||
617 | .Vb "char *" history_search_delimiter_chars | |
618 | The list of additional characters which can delimit a history search | |
619 | string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of | |
620 | a substring search. The default is empty. | |
621 | ||
622 | .Vb int history_quotes_inhibit_expansion | |
775e241e TT |
623 | If non-zero, double-quoted words are not scanned for the history expansion |
624 | character or the history comment character. The default value is 0. | |
9255ee31 EZ |
625 | |
626 | .Vb "rl_linebuf_func_t *" history_inhibit_expansion_function | |
627 | This should be set to the address of a function that takes two arguments: | |
628 | a \fBchar *\fP (\fIstring\fP) | |
629 | and an \fBint\fP index into that string (\fIi\fP). | |
630 | It should return a non-zero value if the history expansion starting at | |
631 | \fIstring[i]\fP should not be performed; zero if the expansion should | |
632 | be done. | |
633 | It is intended for use by applications like \fBbash\fP that use the history | |
634 | expansion character for additional purposes. | |
635 | By default, this variable is set to \fBNULL\fP. | |
636 | .SH FILES | |
637 | .PD 0 | |
638 | .TP | |
639 | .FN ~/.history | |
640 | Default filename for reading and writing saved history | |
641 | .PD | |
642 | .SH "SEE ALSO" | |
643 | .PD 0 | |
644 | .TP | |
645 | \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey | |
646 | .TP | |
647 | \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey | |
648 | .TP | |
649 | \fIbash\fP(1) | |
650 | .TP | |
651 | \fIreadline\fP(3) | |
652 | .PD | |
653 | .SH AUTHORS | |
654 | Brian Fox, Free Software Foundation | |
655 | .br | |
656 | bfox@gnu.org | |
657 | .PP | |
658 | Chet Ramey, Case Western Reserve University | |
659 | .br | |
775e241e | 660 | chet.ramey@case.edu |
9255ee31 EZ |
661 | .SH BUG REPORTS |
662 | If you find a bug in the | |
663 | .B history | |
664 | library, you should report it. But first, you should | |
665 | make sure that it really is a bug, and that it appears in the latest | |
666 | version of the | |
667 | .B history | |
668 | library that you have. | |
669 | .PP | |
670 | Once you have determined that a bug actually exists, mail a | |
671 | bug report to \fIbug\-readline\fP@\fIgnu.org\fP. | |
672 | If you have a fix, you are welcome to mail that | |
673 | as well! Suggestions and `philosophical' bug reports may be mailed | |
674 | to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet | |
675 | newsgroup | |
676 | .BR gnu.bash.bug . | |
677 | .PP | |
678 | Comments and bug reports concerning | |
679 | this manual page should be directed to | |
775e241e | 680 | .IR chet.ramey@case.edu . |