Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11889 > unrolled thread

"fc" builtin exits with unexpected status

Started byChris Marusich <cmmarusich@gmail.com>
First post2015-11-15 19:55 -0800
Last post2015-11-15 19:55 -0800
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  "fc" builtin exits with unexpected status Chris Marusich <cmmarusich@gmail.com> - 2015-11-15 19:55 -0800

#11889 — "fc" builtin exits with unexpected status

FromChris Marusich <cmmarusich@gmail.com>
Date2015-11-15 19:55 -0800
Subject"fc" builtin exits with unexpected status
Message-ID<mailman.2.1447720279.31583.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web