3 <!-- This HTML file has been created by texi2html 1.51
4 from /usr/homes/chet/src/bash/readline-2.2/doc/hist.texinfo on 2 April 1998 -->
6 <TITLE>GNU History Library</TITLE>
9 <H1>GNU History Library</H1>
10 <H2>Edition 2.1, for <CODE>History Library</CODE> Version 2.1.</H2>
12 <ADDRESS>Brian Fox, Free Software Foundation</ADDRESS>
13 <ADDRESS>Chet Ramey, Case Western Reserve University</ADDRESS>
18 @dircategory Libraries
20 * History: (history). The GNU history library API
25 This document describes the GNU History library, a programming tool that
26 provides a consistent user interface for recalling lines of previously
31 Published by the Free Software Foundation <BR>
32 675 Massachusetts Avenue, <BR>
33 Cambridge, MA 02139 USA
37 Permission is granted to make and distribute verbatim copies of
38 this manual provided the copyright notice and this permission notice
39 are preserved on all copies.
43 Permission is granted to copy and distribute modified versions of this
44 manual under the conditions for verbatim copying, provided that the entire
45 resulting derived work is distributed under the terms of a permission
46 notice identical to this one.
50 Permission is granted to copy and distribute translations of this manual
51 into another language, under the above conditions for modified versions,
52 except that this permission notice may be stated in a translation approved
57 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
63 <H1><A NAME="SEC1" HREF="history_toc.html#TOC1">Using History Interactively</A></H1>
66 This chapter describes how to use the GNU History Library interactively,
67 from a user's standpoint. It should be considered a user's guide. For
68 information on using the GNU History Library in your own programs,
69 see section <A HREF="history.html#SEC6">Programming with GNU History</A>.
75 <H2><A NAME="SEC2" HREF="history_toc.html#TOC2">History Expansion</A></H2>
81 The History library provides a history expansion feature that is similar
82 to the history expansion provided by <CODE>csh</CODE>. This section
83 describes the syntax used to manipulate the history information.
87 History expansions introduce words from the history list into
88 the input stream, making it easy to repeat commands, insert the
89 arguments to a previous command into the current input line, or
90 fix errors in previous commands quickly.
94 History expansion takes place in two parts. The first is to determine
95 which line from the history list should be used during substitution.
96 The second is to select portions of that line for inclusion into the
97 current one. The line selected from the history is called the
98 <STRONG>event</STRONG>, and the portions of that line that are acted upon are
99 called <STRONG>words</STRONG>. Various <STRONG>modifiers</STRONG> are available to manipulate
100 the selected words. The line is broken into words in the same fashion
101 that Bash does, so that several words
102 surrounded by quotes are considered one word.
103 History expansions are introduced by the appearance of the
104 history expansion character, which is <SAMP>`!'</SAMP> by default.
110 <H3><A NAME="SEC3" HREF="history_toc.html#TOC3">Event Designators</A></H3>
116 An event designator is a reference to a command line entry in the
125 Start a history substitution, except when followed by a space, tab,
126 the end of the line, <SAMP>`='</SAMP> or <SAMP>`('</SAMP>.
128 <DT><CODE>!<VAR>n</VAR></CODE>
130 Refer to command line <VAR>n</VAR>.
132 <DT><CODE>!-<VAR>n</VAR></CODE>
134 Refer to the command <VAR>n</VAR> lines back.
138 Refer to the previous command. This is a synonym for <SAMP>`!-1'</SAMP>.
140 <DT><CODE>!<VAR>string</VAR></CODE>
142 Refer to the most recent command starting with <VAR>string</VAR>.
144 <DT><CODE>!?<VAR>string</VAR>[?]</CODE>
146 Refer to the most recent command containing <VAR>string</VAR>. The trailing
147 <SAMP>`?'</SAMP> may be omitted if the <VAR>string</VAR> is followed immediately by
150 <DT><CODE>^<VAR>string1</VAR>^<VAR>string2</VAR>^</CODE>
152 Quick Substitution. Repeat the last command, replacing <VAR>string1</VAR>
153 with <VAR>string2</VAR>. Equivalent to
154 <CODE>!!:s/<VAR>string1</VAR>/<VAR>string2</VAR>/</CODE>.
158 The entire command line typed so far.
164 <H3><A NAME="SEC4" HREF="history_toc.html#TOC4">Word Designators</A></H3>
167 Word designators are used to select desired words from the event.
168 A <SAMP>`:'</SAMP> separates the event specification from the word designator. It
169 may be omitted if the word designator begins with a <SAMP>`^'</SAMP>, <SAMP>`$'</SAMP>,
170 <SAMP>`*'</SAMP>, <SAMP>`-'</SAMP>, or <SAMP>`%'</SAMP>. Words are numbered from the beginning
171 of the line, with the first word being denoted by 0 (zero). Words are
172 inserted into the current line separated by single spaces.
177 <DT><CODE>0 (zero)</CODE>
179 The <CODE>0</CODE>th word. For many applications, this is the command word.
181 <DT><CODE><VAR>n</VAR></CODE>
183 The <VAR>n</VAR>th word.
187 The first argument; that is, word 1.
195 The word matched by the most recent <SAMP>`?<VAR>string</VAR>?'</SAMP> search.
197 <DT><CODE><VAR>x</VAR>-<VAR>y</VAR></CODE>
199 A range of words; <SAMP>`-<VAR>y</VAR>'</SAMP> abbreviates <SAMP>`0-<VAR>y</VAR>'</SAMP>.
203 All of the words, except the <CODE>0</CODE>th. This is a synonym for <SAMP>`1-$'</SAMP>.
204 It is not an error to use <SAMP>`*'</SAMP> if there is just one word in the event;
205 the empty string is returned in that case.
207 <DT><CODE><VAR>x</VAR>*</CODE>
209 Abbreviates <SAMP>`<VAR>x</VAR>-$'</SAMP>
211 <DT><CODE><VAR>x</VAR>-</CODE>
213 Abbreviates <SAMP>`<VAR>x</VAR>-$'</SAMP> like <SAMP>`<VAR>x</VAR>*'</SAMP>, but omits the last word.
218 If a word designator is supplied without an event specification, the
219 previous command is used as the event.
224 <H3><A NAME="SEC5" HREF="history_toc.html#TOC5">Modifiers</A></H3>
227 After the optional word designator, you can add a sequence of one or more
228 of the following modifiers, each preceded by a <SAMP>`:'</SAMP>.
235 Remove a trailing pathname component, leaving only the head.
239 Remove all leading pathname components, leaving the tail.
243 Remove a trailing suffix of the form <SAMP>`.<VAR>suffix</VAR>'</SAMP>, leaving
248 Remove all but the trailing suffix.
252 Print the new command but do not execute it.
254 <DT><CODE>s/<VAR>old</VAR>/<VAR>new</VAR>/</CODE>
256 Substitute <VAR>new</VAR> for the first occurrence of <VAR>old</VAR> in the
257 event line. Any delimiter may be used in place of <SAMP>`/'</SAMP>.
258 The delimiter may be quoted in <VAR>old</VAR> and <VAR>new</VAR>
259 with a single backslash. If <SAMP>`&'</SAMP> appears in <VAR>new</VAR>,
260 it is replaced by <VAR>old</VAR>. A single backslash will quote
261 the <SAMP>`&'</SAMP>. The final delimiter is optional if it is the last
262 character on the input line.
264 <DT><CODE>&</CODE>
266 Repeat the previous substitution.
270 Cause changes to be applied over the entire event line. Used in
271 conjunction with <SAMP>`s'</SAMP>, as in <CODE>gs/<VAR>old</VAR>/<VAR>new</VAR>/</CODE>,
272 or with <SAMP>`&'</SAMP>.
278 <H1><A NAME="SEC6" HREF="history_toc.html#TOC6">Programming with GNU History</A></H1>
281 This chapter describes how to interface programs that you write
282 with the GNU History Library.
283 It should be considered a technical guide.
284 For information on the interactive use of GNU History, see section <A HREF="history.html#SEC1">Using History Interactively</A>.
290 <H2><A NAME="SEC7" HREF="history_toc.html#TOC7">Introduction to History</A></H2>
293 Many programs read input from the user a line at a time. The GNU History
294 library is able to keep track of those lines, associate arbitrary data with
295 each line, and utilize information from previous lines in composing new
300 The programmer using the History library has available functions
301 for remembering lines on a history list, associating arbitrary data
302 with a line, removing lines from the list, searching through the list
303 for a line containing an arbitrary text string, and referencing any line
304 in the list directly. In addition, a history <STRONG>expansion</STRONG> function
305 is available which provides for a consistent user interface across
310 The user using programs written with the History library has the
311 benefit of a consistent user interface with a set of well-known
312 commands for manipulating the text of previous lines and using that text
313 in new commands. The basic history manipulation commands are similar to
314 the history substitution provided by <CODE>csh</CODE>.
318 If the programmer desires, he can use the Readline library, which
319 includes some history manipulation by default, and has the added
320 advantage of command line editing.
325 <H2><A NAME="SEC8" HREF="history_toc.html#TOC8">History Storage</A></H2>
328 The history list is an array of history entries. A history entry is
334 typedef struct _hist_entry {
341 The history list itself might therefore be declared as
346 HIST_ENTRY **the_history_list;
350 The state of the History library is encapsulated into a single structure:
355 /* A structure used to pass the current state of the history stuff around. */
356 typedef struct _hist_state {
357 HIST_ENTRY **entries; /* Pointer to the entries themselves. */
358 int offset; /* The location pointer within this array. */
359 int length; /* Number of elements within this array. */
360 int size; /* Number of slots allocated to this array. */
366 If the flags member includes <CODE>HS_STIFLED</CODE>, the history has been
372 <H2><A NAME="SEC9" HREF="history_toc.html#TOC9">History Functions</A></H2>
375 This section describes the calling sequence for the various functions
376 present in GNU History.
382 <H3><A NAME="SEC10" HREF="history_toc.html#TOC10">Initializing History and State Management</A></H3>
385 This section describes functions used to initialize and manage
386 the state of the History library when you want to use the history
387 functions in your program.
392 <DT><U>Function:</U> void <B>using_history</B> <I>()</I>
393 <DD><A NAME="IDX4"></A>
394 Begin a session in which the history functions might be used. This
395 initializes the interactive variables.
401 <DT><U>Function:</U> HISTORY_STATE * <B>history_get_history_state</B> <I>()</I>
402 <DD><A NAME="IDX5"></A>
403 Return a structure describing the current state of the input history.
409 <DT><U>Function:</U> void <B>history_set_history_state</B> <I>(HISTORY_STATE *state)</I>
410 <DD><A NAME="IDX6"></A>
411 Set the state of the history list according to <VAR>state</VAR>.
417 <H3><A NAME="SEC11" HREF="history_toc.html#TOC11">History List Management</A></H3>
420 These functions manage individual entries on the history list, or set
421 parameters managing the list itself.
426 <DT><U>Function:</U> void <B>add_history</B> <I>(char *string)</I>
427 <DD><A NAME="IDX7"></A>
428 Place <VAR>string</VAR> at the end of the history list. The associated data
429 field (if any) is set to <CODE>NULL</CODE>.
435 <DT><U>Function:</U> HIST_ENTRY * <B>remove_history</B> <I>(int which)</I>
436 <DD><A NAME="IDX8"></A>
437 Remove history entry at offset <VAR>which</VAR> from the history. The
438 removed element is returned so you can free the line, data,
439 and containing structure.
445 <DT><U>Function:</U> HIST_ENTRY * <B>replace_history_entry</B> <I>(int which, char *line, char *data)</I>
446 <DD><A NAME="IDX9"></A>
447 Make the history entry at offset <VAR>which</VAR> have <VAR>line</VAR> and <VAR>data</VAR>.
448 This returns the old entry so you can dispose of the data. In the case
449 of an invalid <VAR>which</VAR>, a <CODE>NULL</CODE> pointer is returned.
455 <DT><U>Function:</U> void <B>clear_history</B> <I>()</I>
456 <DD><A NAME="IDX10"></A>
457 Clear the history list by deleting all the entries.
463 <DT><U>Function:</U> void <B>stifle_history</B> <I>(int max)</I>
464 <DD><A NAME="IDX11"></A>
465 Stifle the history list, remembering only the last <VAR>max</VAR> entries.
471 <DT><U>Function:</U> int <B>unstifle_history</B> <I>()</I>
472 <DD><A NAME="IDX12"></A>
473 Stop stifling the history. This returns the previous amount the
474 history was stifled. The value is positive if the history was
475 stifled, negative if it wasn't.
481 <DT><U>Function:</U> int <B>history_is_stifled</B> <I>()</I>
482 <DD><A NAME="IDX13"></A>
483 Returns non-zero if the history is stifled, zero if it is not.
489 <H3><A NAME="SEC12" HREF="history_toc.html#TOC12">Information About the History List</A></H3>
492 These functions return information about the entire history list or
493 individual list entries.
498 <DT><U>Function:</U> HIST_ENTRY ** <B>history_list</B> <I>()</I>
499 <DD><A NAME="IDX14"></A>
500 Return a <CODE>NULL</CODE> terminated array of <CODE>HIST_ENTRY</CODE> which is the
501 current input history. Element 0 of this list is the beginning of time.
502 If there is no history, return <CODE>NULL</CODE>.
508 <DT><U>Function:</U> int <B>where_history</B> <I>()</I>
509 <DD><A NAME="IDX15"></A>
510 Returns the offset of the current history element.
516 <DT><U>Function:</U> HIST_ENTRY * <B>current_history</B> <I>()</I>
517 <DD><A NAME="IDX16"></A>
518 Return the history entry at the current position, as determined by
519 <CODE>where_history ()</CODE>. If there is no entry there, return a <CODE>NULL</CODE>
526 <DT><U>Function:</U> HIST_ENTRY * <B>history_get</B> <I>(int offset)</I>
527 <DD><A NAME="IDX17"></A>
528 Return the history entry at position <VAR>offset</VAR>, starting from
529 <CODE>history_base</CODE>. If there is no entry there, or if <VAR>offset</VAR>
530 is greater than the history length, return a <CODE>NULL</CODE> pointer.
536 <DT><U>Function:</U> int <B>history_total_bytes</B> <I>()</I>
537 <DD><A NAME="IDX18"></A>
538 Return the number of bytes that the primary history entries are using.
539 This function returns the sum of the lengths of all the lines in the
546 <H3><A NAME="SEC13" HREF="history_toc.html#TOC13">Moving Around the History List</A></H3>
549 These functions allow the current index into the history list to be
555 <DT><U>Function:</U> int <B>history_set_pos</B> <I>(int pos)</I>
556 <DD><A NAME="IDX19"></A>
557 Set the position in the history list to <VAR>pos</VAR>, an absolute index
564 <DT><U>Function:</U> HIST_ENTRY * <B>previous_history</B> <I>()</I>
565 <DD><A NAME="IDX20"></A>
566 Back up the current history offset to the previous history entry, and
567 return a pointer to that entry. If there is no previous entry, return
568 a <CODE>NULL</CODE> pointer.
574 <DT><U>Function:</U> HIST_ENTRY * <B>next_history</B> <I>()</I>
575 <DD><A NAME="IDX21"></A>
576 Move the current history offset forward to the next history entry, and
577 return the a pointer to that entry. If there is no next entry, return
578 a <CODE>NULL</CODE> pointer.
584 <H3><A NAME="SEC14" HREF="history_toc.html#TOC14">Searching the History List</A></H3>
590 These functions allow searching of the history list for entries containing
591 a specific string. Searching may be performed both forward and backward
592 from the current history position. The search may be <STRONG>anchored</STRONG>,
593 meaning that the string must match at the beginning of the history entry.
599 <DT><U>Function:</U> int <B>history_search</B> <I>(char *string, int direction)</I>
600 <DD><A NAME="IDX24"></A>
601 Search the history for <VAR>string</VAR>, starting at the current history
602 offset. If <VAR>direction</VAR> < 0, then the search is through previous entries,
603 else through subsequent. If <VAR>string</VAR> is found, then
604 the current history index is set to that history entry, and the value
605 returned is the offset in the line of the entry where
606 <VAR>string</VAR> was found. Otherwise, nothing is changed, and a -1 is
613 <DT><U>Function:</U> int <B>history_search_prefix</B> <I>(char *string, int direction)</I>
614 <DD><A NAME="IDX25"></A>
615 Search the history for <VAR>string</VAR>, starting at the current history
616 offset. The search is anchored: matching lines must begin with
617 <VAR>string</VAR>. If <VAR>direction</VAR> < 0, then the search is through previous
618 entries, else through subsequent. If <VAR>string</VAR> is found, then the
619 current history index is set to that entry, and the return value is 0.
620 Otherwise, nothing is changed, and a -1 is returned.
626 <DT><U>Function:</U> int <B>history_search_pos</B> <I>(char *string, int direction, int pos)</I>
627 <DD><A NAME="IDX26"></A>
628 Search for <VAR>string</VAR> in the history list, starting at <VAR>pos</VAR>, an
629 absolute index into the list. If <VAR>direction</VAR> is negative, the search
630 proceeds backward from <VAR>pos</VAR>, otherwise forward. Returns the absolute
631 index of the history element where <VAR>string</VAR> was found, or -1 otherwise.
637 <H3><A NAME="SEC15" HREF="history_toc.html#TOC15">Managing the History File</A></H3>
640 The History library can read the history from and write it to a file.
641 This section documents the functions for managing a history file.
646 <DT><U>Function:</U> int <B>read_history</B> <I>(char *filename)</I>
647 <DD><A NAME="IDX27"></A>
648 Add the contents of <VAR>filename</VAR> to the history list, a line at a
649 time. If <VAR>filename</VAR> is <CODE>NULL</CODE>, then read from
650 <TT>`~/.history'</TT>. Returns 0 if successful, or errno if not.
656 <DT><U>Function:</U> int <B>read_history_range</B> <I>(char *filename, int from, int to)</I>
657 <DD><A NAME="IDX28"></A>
658 Read a range of lines from <VAR>filename</VAR>, adding them to the history list.
659 Start reading at line <VAR>from</VAR> and end at <VAR>to</VAR>. If
660 <VAR>from</VAR> is zero, start at the beginning. If <VAR>to</VAR> is less than
661 <VAR>from</VAR>, then read until the end of the file. If <VAR>filename</VAR> is
662 <CODE>NULL</CODE>, then read from <TT>`~/.history'</TT>. Returns 0 if successful,
663 or <CODE>errno</CODE> if not.
669 <DT><U>Function:</U> int <B>write_history</B> <I>(char *filename)</I>
670 <DD><A NAME="IDX29"></A>
671 Write the current history to <VAR>filename</VAR>, overwriting <VAR>filename</VAR>
672 if necessary. If <VAR>filename</VAR> is
673 <CODE>NULL</CODE>, then write the history list to <TT>`~/.history'</TT>. Values
674 returned are as in <CODE>read_history ()</CODE>.
680 <DT><U>Function:</U> int <B>append_history</B> <I>(int nelements, char *filename)</I>
681 <DD><A NAME="IDX30"></A>
682 Append the last <VAR>nelements</VAR> of the history list to <VAR>filename</VAR>.
688 <DT><U>Function:</U> int <B>history_truncate_file</B> <I>(char *filename, int nlines)</I>
689 <DD><A NAME="IDX31"></A>
690 Truncate the history file <VAR>filename</VAR>, leaving only the last
691 <VAR>nlines</VAR> lines.
697 <H3><A NAME="SEC16" HREF="history_toc.html#TOC16">History Expansion</A></H3>
700 These functions implement <CODE>csh</CODE>-like history expansion.
705 <DT><U>Function:</U> int <B>history_expand</B> <I>(char *string, char **output)</I>
706 <DD><A NAME="IDX32"></A>
707 Expand <VAR>string</VAR>, placing the result into <VAR>output</VAR>, a pointer
708 to a string (see section <A HREF="history.html#SEC2">History Expansion</A>). Returns:
713 If no expansions took place (or, if the only change in
714 the text was the de-slashifying of the history expansion
718 if expansions did take place;
721 if there was an error in expansion;
724 if the returned line should only be displayed, but not executed,
725 as with the <CODE>:p</CODE> modifier (see section <A HREF="history.html#SEC5">Modifiers</A>).
729 If an error ocurred in expansion, then <VAR>output</VAR> contains a descriptive
736 <DT><U>Function:</U> char * <B>history_arg_extract</B> <I>(int first, int last, char *string)</I>
737 <DD><A NAME="IDX33"></A>
738 Extract a string segment consisting of the <VAR>first</VAR> through <VAR>last</VAR>
739 arguments present in <VAR>string</VAR>. Arguments are broken up as in Bash.
745 <DT><U>Function:</U> char * <B>get_history_event</B> <I>(char *string, int *cindex, int qchar)</I>
746 <DD><A NAME="IDX34"></A>
747 Returns the text of the history event beginning at <VAR>string</VAR> +
748 <VAR>*cindex</VAR>. <VAR>*cindex</VAR> is modified to point to after the event
749 specifier. At function entry, <VAR>cindex</VAR> points to the index into
750 <VAR>string</VAR> where the history event specification begins. <VAR>qchar</VAR>
751 is a character that is allowed to end the event specification in addition
752 to the "normal" terminating characters.
758 <DT><U>Function:</U> char ** <B>history_tokenize</B> <I>(char *string)</I>
759 <DD><A NAME="IDX35"></A>
760 Return an array of tokens parsed out of <VAR>string</VAR>, much as the
761 shell might. The tokens are split on white space and on the
762 characters <CODE>()<>;&|$</CODE>, and shell quoting conventions are
769 <H2><A NAME="SEC17" HREF="history_toc.html#TOC17">History Variables</A></H2>
772 This section describes the externally visible variables exported by
773 the GNU History Library.
778 <DT><U>Variable:</U> int <B>history_base</B>
779 <DD><A NAME="IDX36"></A>
780 The logical offset of the first entry in the history list.
786 <DT><U>Variable:</U> int <B>history_length</B>
787 <DD><A NAME="IDX37"></A>
788 The number of entries currently stored in the history list.
794 <DT><U>Variable:</U> int <B>max_input_history</B>
795 <DD><A NAME="IDX38"></A>
796 The maximum number of history entries. This must be changed using
797 <CODE>stifle_history ()</CODE>.
803 <DT><U>Variable:</U> char <B>history_expansion_char</B>
804 <DD><A NAME="IDX39"></A>
805 The character that starts a history event. The default is <SAMP>`!'</SAMP>.
811 <DT><U>Variable:</U> char <B>history_subst_char</B>
812 <DD><A NAME="IDX40"></A>
813 The character that invokes word substitution if found at the start of
814 a line. The default is <SAMP>`^'</SAMP>.
820 <DT><U>Variable:</U> char <B>history_comment_char</B>
821 <DD><A NAME="IDX41"></A>
822 During tokenization, if this character is seen as the first character
823 of a word, then it and all subsequent characters up to a newline are
824 ignored, suppressing history expansion for the remainder of the line.
825 This is disabled by default.
831 <DT><U>Variable:</U> char * <B>history_no_expand_chars</B>
832 <DD><A NAME="IDX42"></A>
833 The list of characters which inhibit history expansion if found immediately
834 following <VAR>history_expansion_char</VAR>. The default is whitespace and
841 <DT><U>Variable:</U> char * <B>history_search_delimiter_chars</B>
842 <DD><A NAME="IDX43"></A>
843 The list of additional characters which can delimit a history search
844 string, in addition to whitespace, <SAMP>`:'</SAMP> and <SAMP>`?'</SAMP> in the case of
845 a substring search. The default is empty.
851 <DT><U>Variable:</U> int <B>history_quotes_inhibit_expansion</B>
852 <DD><A NAME="IDX44"></A>
853 If non-zero, single-quoted words are not scanned for the history expansion
854 character. The default value is 0.
860 <DT><U>Variable:</U> Function * <B>history_inhibit_expansion_function</B>
861 <DD><A NAME="IDX45"></A>
862 This should be set to the address of a function that takes two arguments:
863 a <CODE>char *</CODE> (<VAR>string</VAR>) and an integer index into that string (<VAR>i</VAR>).
864 It should return a non-zero value if the history expansion starting at
865 <VAR>string[i]</VAR> should not be performed; zero if the expansion should
867 It is intended for use by applications like Bash that use the history
868 expansion character for additional purposes.
869 By default, this variable is set to NULL.
875 <H2><A NAME="SEC18" HREF="history_toc.html#TOC18">History Programming Example</A></H2>
878 The following program demonstrates simple use of the GNU History Library.
893 printf ("history$ ");
895 t = fgets (line, sizeof (line) - 1, stdin);
899 if (t[len - 1] == '\n')
904 strcpy (line, "quit");
911 result = history_expand (line, &expansion);
913 fprintf (stderr, "%s\n", expansion);
915 if (result < 0 || result == 2)
921 add_history (expansion);
922 strncpy (line, expansion, sizeof (line) - 1);
926 if (strcmp (line, "quit") == 0)
928 else if (strcmp (line, "save") == 0)
929 write_history ("history_file");
930 else if (strcmp (line, "read") == 0)
931 read_history ("history_file");
932 else if (strcmp (line, "list") == 0)
934 register HIST_ENTRY **the_list;
937 the_list = history_list ();
939 for (i = 0; the_list[i]; i++)
940 printf ("%d: %s\n", i + history_base, the_list[i]->line);
942 else if (strncmp (line, "delete", 6) == 0)
945 if ((sscanf (line + 6, "%d", &which)) == 1)
947 HIST_ENTRY *entry = remove_history (which);
949 fprintf (stderr, "No such entry %d\n", which);
952 free (entry->line);
958 fprintf (stderr, "non-numeric arg given to `delete'\n");
967 <H1><A NAME="SEC19" HREF="history_toc.html#TOC19">Concept Index</A></H1>
971 <LI><A HREF="history.html#IDX23">anchored search</A>
975 <LI><A HREF="history.html#IDX2">event designators</A>
979 <LI><A HREF="history.html#IDX3">history events</A>
980 <LI><A HREF="history.html#IDX1">history expansion</A>
981 <LI><A HREF="history.html#IDX22">History Searching</A>
987 <H1><A NAME="SEC20" HREF="history_toc.html#TOC20">Function and Variable Index</A></H1>
991 <LI><A HREF="history.html#IDX7">add_history</A>
992 <LI><A HREF="history.html#IDX30">append_history</A>
996 <LI><A HREF="history.html#IDX10">clear_history</A>
997 <LI><A HREF="history.html#IDX16">current_history</A>
1001 <LI><A HREF="history.html#IDX34">get_history_event</A>
1005 <LI><A HREF="history.html#IDX33">history_arg_extract</A>
1006 <LI><A HREF="history.html#IDX36">history_base</A>
1007 <LI><A HREF="history.html#IDX41">history_comment_char</A>
1008 <LI><A HREF="history.html#IDX32">history_expand</A>
1009 <LI><A HREF="history.html#IDX39">history_expansion_char</A>
1010 <LI><A HREF="history.html#IDX17">history_get</A>
1011 <LI><A HREF="history.html#IDX5">history_get_history_state</A>
1012 <LI><A HREF="history.html#IDX45">history_inhibit_expansion_function</A>
1013 <LI><A HREF="history.html#IDX13">history_is_stifled</A>
1014 <LI><A HREF="history.html#IDX37">history_length</A>
1015 <LI><A HREF="history.html#IDX14">history_list</A>
1016 <LI><A HREF="history.html#IDX42">history_no_expand_chars</A>
1017 <LI><A HREF="history.html#IDX44">history_quotes_inhibit_expansion</A>
1018 <LI><A HREF="history.html#IDX24">history_search</A>
1019 <LI><A HREF="history.html#IDX43">history_search_delimiter_chars</A>
1020 <LI><A HREF="history.html#IDX26">history_search_pos</A>
1021 <LI><A HREF="history.html#IDX25">history_search_prefix</A>
1022 <LI><A HREF="history.html#IDX6">history_set_history_state</A>
1023 <LI><A HREF="history.html#IDX19">history_set_pos</A>
1024 <LI><A HREF="history.html#IDX40">history_subst_char</A>
1025 <LI><A HREF="history.html#IDX35">history_tokenize</A>
1026 <LI><A HREF="history.html#IDX18">history_total_bytes</A>
1027 <LI><A HREF="history.html#IDX31">history_truncate_file</A>
1031 <LI><A HREF="history.html#IDX38">max_input_history</A>
1035 <LI><A HREF="history.html#IDX21">next_history</A>
1039 <LI><A HREF="history.html#IDX20">previous_history</A>
1043 <LI><A HREF="history.html#IDX27">read_history</A>
1044 <LI><A HREF="history.html#IDX28">read_history_range</A>
1045 <LI><A HREF="history.html#IDX8">remove_history</A>
1046 <LI><A HREF="history.html#IDX9">replace_history_entry</A>
1050 <LI><A HREF="history.html#IDX11">stifle_history</A>
1054 <LI><A HREF="history.html#IDX12">unstifle_history</A>
1055 <LI><A HREF="history.html#IDX4">using_history</A>
1059 <LI><A HREF="history.html#IDX15">where_history</A>
1060 <LI><A HREF="history.html#IDX29">write_history</A>
1065 This document was generated on 2 April 1998 using the
1066 <A HREF="http://wwwcn.cern.ch/dci/texi2html/">texi2html</A>
1067 translator version 1.51.</P>