[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.3.7 History Expansion
These functions implement history expansion.
- Function: int history_expand (char *string, char **output)
Expand string, placing the result into output, a pointer to a string (see section History Expansion). Returns:
-
0
If no expansions took place (or, if the only change in the text was the removal of escape characters preceding the history expansion character);
-
1
if expansions did take place;
-
-1
if there was an error in expansion;
-
2
if the returned line should be displayed, but not executed, as with the
:p
modifier (see section Modifiers).
If an error ocurred in expansion, then output contains a descriptive error message.
-
- Function: char * get_history_event (const 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 (const char *string)
Return an array of tokens parsed out of string, much as the shell might. The tokens are split on the characters in the history_word_delimiters variable, and shell quoting conventions are obeyed.
- Function: char * history_arg_extract (int first, int last, const char *string)
Extract a string segment consisting of the first through last arguments present in string. Arguments are split using
history_tokenize
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |