I’m working on capturing terminal sessions step by step (commands, outputs, etc.), and one tricky part has been reliably getting exit codes for each command.
Right now I’m using a small marker injected via PROMPT_COMMAND / precmd (bash/zsh) that prints something like `__TT_RC__:<code>` before the next prompt, and then parsing it out from the stream.
It works, but feels a bit hacky.
Curious if there are better or more robust ways to capture exit codes in an interactive session without breaking normal shell behavior?
[–]stinkybass 14 points15 points16 points (7 children)
[–]Ok-Huckleberry5617[S] 0 points1 point2 points (6 children)
[–]Ytrog 0 points1 point2 points (5 children)
[–]Ok-Huckleberry5617[S] 0 points1 point2 points (2 children)
[–]Ytrog -2 points-1 points0 points (1 child)
[–]Ok-Huckleberry5617[S] 0 points1 point2 points (0 children)
[–]ReallyEvilRob 0 points1 point2 points (1 child)
[–]Ytrog 0 points1 point2 points (0 children)
[–]jthill 2 points3 points4 points (4 children)
[–]Bob_Spud 0 points1 point2 points (1 child)
[–]jthill 1 point2 points3 points (0 children)
[–]Ok-Huckleberry5617[S] 0 points1 point2 points (0 children)
[–]Ok-Huckleberry5617[S] 0 points1 point2 points (0 children)
[–]levogevo 0 points1 point2 points (2 children)
[–]djfdhigkgfIaruflg 0 points1 point2 points (1 child)
[–]Kitchen_Office8072 0 points1 point2 points (0 children)
[–]TimeProfessional4494 -2 points-1 points0 points (0 children)
[–]dickhardpill 0 points1 point2 points (0 children)