'Is there C function to handle any shell history?

I wrote a command-line tool in C/C++. When it quit, I need to add a line to the current shell history.

For now, I wrap my tool in a shell command, using history -w and history -r for bash or fc -W and fc -W for zsh in order to add my line to the shell history (by appending a line to $HISTFILE then reloading it).

Is there a C function to handle history (append line, write file, reload history) for any *NIX shell, to avoid having to wrap my tool with specific shell stuffs ?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source