Re:How to determine which commands failed/succeeded in your ...
by jolmg on Tuesday December 04, 2018 @08:10PM
(#18604968)
> Do I need to write my own bash_history program for this? Would like to avoid that.
I didn't even know about HISTTIMEFORMAT, but seeing as how it puts the time in a "comment", which I didn't even know was possible for these readline history files, maybe there's some bash hook you can define that will have access to the return code of each command run and append that to the history file with a comment character on your own. This working depends on having configured bash so that it writes to the history file incrementally (as soon as each command is run and not until you exit bash).
If that fails, in your shoes, I would look into patching bash. I don't think you'll find explicit support for what you want (you've already looked in the documentation, right?), but I'd be happy to be proven wrong.
I didn't even know about HISTTIMEFORMAT, but seeing as how it puts the time in a "comment", which I didn't even know was possible for these readline history files, maybe there's some bash hook you can define that will have access to the return code of each command run and append that to the history file with a comment character on your own. This working depends on having configured bash so that it writes to the history file incrementally (as soon as each command is run and not until you exit bash).
If that fails, in your shoes, I would look into patching bash. I don't think you'll find explicit support for what you want (you've already looked in the documentation, right?), but I'd be happy to be proven wrong.