> > Something I recommend to all serious Unix users is to put the exit status > in the shell prompt.
Alternatively, you can indicate a non-zero exit status by displaying a prompt symbol in a different colour than usual. This might be preferable for folks who prefer fixed-width and/or minimalist prompt strings. For example, my own prompt string <https://github.com/Alhadis/.files/blob/a8428816cf4b09ddd73150bfc0f58a8ae2af54b4/prompt.sh> uses a dimmed “λ” in graphical (true colour) environments, and a red “$” for purely-textual displays like fbdev(4) and wscons(4). It boils down to something like this: colour='\033[32m'; # Normal prompt-symbol colour PS1="\$([ \$? -eq 0 ] && printf '$colour' || printf '\033[31m')\$${colour}" Basically, if I care about the exit status, I can always run `echo $?`. Most of the time, I don't (it's enough to know that an error occurred from the colour alone), so it's not worth cluttering my terminal window with unnecessary information. Regards, — John On Sun, 5 Feb 2023 at 08:56, G. Branden Robinson < g.branden.robin...@gmail.com> wrote: > Hi Peter, > > At 2023-02-04T16:09:55-0500, Peter Schaffter wrote: > > The reasoning makes sense but now you have to jump through a hoop > > when you're using .ab for debugging. I usually debug with the -z > > flag. Formerly, > > > > echo -e ".nr foo 1\n.if r foo .ab\n" | groff -z > > > > would helpfully spit out "User abort." Now there's no way to know > > whether groff exited cleanly or aborted unless you add a string > > after .ab. (A minor annoyance, but I thought I should mention it.) > > There _is_ a way... :) > > Something I recommend to all serious Unix users is to put the exit > status in the shell prompt. I learned this trick early because too many > times when working interactively, by the time I realize I want to know > something's exit status, it is too late and $? has been clobbered. > > Here's an abbreviated form of my Bash prompt. I note that the "($?)" > part is thoroughly portable. _All_ POSIX, Bourne-, or Korn-descended > shells should support it. > > PS1='\D{%F} \t \s-\v [\l] {\j} ($?) \u@\h:\w !\!\$ ' > > Regards, > Branden >