GNU History Library. Node: History Expansion

PREVManaging the History File UPHistory Functions next

2.3.7: History Expansion

These functions implement csh-like history expansion.

Function: int history_expand (char *string, char **output)
Expand string, placing the result into output, a pointer to a string (see History Interaction). Returns:

If no expansions took place (or, if the only change in the text was the de-slashifying of the history expansion character);

1 if expansions did take place;
-1 if there was an error in expansion;
2 if the returned line should only be displayed, but not executed, as with the :p modifier (see Modifiers).

If an error ocurred in expansion, then output contains a descriptive error message.

Function: char * history_arg_extract (int first, int last, char *string)
Extract a string segment consisting of the first through last arguments present in string. Arguments are broken up as in Bash.
Function: char * get_history_event (char *string, int *cindex, int qchar)
Returns the text of the history event beginning at string + *cindex. *cindex is modified to point to after the event specifier. At function entry, cindex points to the index into string where the history event specification begins. qchar is a character that is allowed to end the event specification in addition to the ``normal'' terminating characters.
Function: char ** history_tokenize (char *string)
Return an array of tokens parsed out of string, much as the shell might. The tokens are split on white space and on the characters ()<>;&|$, and shell quoting conventions are obeyed.
PREVManaging the History File UPHistory Functions next