Hi, I like to set up my PS1 to show the exit status of the last command I ran. I've noticed that this doesn't seem to work as expected when I use the "fc" builtin. When I do the following, the final exit status appears to be reported as "1", even though true always exits with status 0.
$ export PS1='[$?] \$ ' [0] $ false [1] $ true [0] $ fc true [1] $ To be clear, after invoking fc, I type in the command "true" on a single line, save, and exit my editor. To rule out the possibility that the editor was somehow related, I tried this with both emacs and vim (by setting the EDITOR environment variable), and the unexpected behavior occurs the same in both cases. The problem also occurs regardless of whether I use the "true" builtin or the "true" program (e.g., /bin/true). The help for the "fc" builtin says that it "returns success or status of executed command; non-zero if an error occurs." Based on that, here's what I expected to see (but did not): $ export PS1='[$?] \$ ' [0] $ false [1] $ true [0] $ fc true [0] $ This problem has been confirmed by two others (izabera and annihilannic) in the Freenode #bash IRC chat room. We have confirmed that the following bash versions exhibit this unexpected behavior: - 4.3.39(1)-release, on a GuixSD system - 4.2.46(1)-release, on a CentOS 7 system - 4.3.42 - izabera also confirmed that the unexpected behavior occurs "in the devel", which I presume means the latest development branch of GNU bash. I hope this is enough information to help figure out what the problem is and fix it. Thank you, Chris Marusich