On Thu, Nov 7, 2019 at 12:09 PM Chet Ramey <chet.ra...@case.edu> wrote: > > On 11/5/19 12:49 PM, Daniel Colascione wrote: > > Right now, bash history saves only the command line actually executed. > > This isn't quite the case. What it saves is the line returned from > readline, before it's expanded or executed.
Fair enough. > > Why not also, optionally, save command execution times and exit > > statuses? This information is practically free to collect. > > Because by the time you gather this information, the command has already > been saved completely. > > There have been various proposals to extend the timestamp with additional > information, but it's all data you can gather when the timestamp is saved > before the command is executed. That's how history works today, yes. I'm wondering whether it'd be possible to maintain an auxiliary history that included not only the command lines read, but also their execution time and outcome. Doing something in PROMPT_COMMAND doesn't seem quite accurate. Maybe what I really want is something like $?, but instead of containing exit status, it would contain information from a struct rusage (derived from wait4) for the last command. Or something like that anyway. The larger point is that the shell could gather this information proactively almost for free and I don't think user code running in existing shell extension points can do the same job.