Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Chris Marusich Newsgroups: gnu.bash.bug Subject: "fc" builtin exits with unexpected status Date: Sun, 15 Nov 2015 19:55:33 -0800 Lines: 51 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: usenet.stanford.edu 1447720279 6200 208.118.235.17 (17 Nov 2015 00:31:19 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=5UmaUF8VoUGfgjhC0g5RokyczTLwgW9wUGBStaB7c1E=; b=rYVQD8eMQZBpSckwUcITV5j6YvbovtjPxnAo59gTea33c3EBeFC62uWBt3H+X09oAt qGm5QJfHTt/nWVFC1pUevmhECoagphYTyzMrmKbMlVb3eH8gpLdB2LCdbFE1nurP5OpO B8XicLlZJtwH556z5VrROmz2KSxBT/EmEldulUzogAjv8Xu16Fb+c+C7rayHjJLsAWuZ A3ghsAuiZfp3Hzf73pi8k4tfEZiICWihH8VMloF+VciYZjSxshC7tNkp9OkbX2wBDJz5 heUrsxlHPLId/YcIffLXQ2jh7mEHGf48FjyYplc9YXrWNL4QRdRStp/51NFyMhovVQq7 EhXA== X-Received: by 10.60.102.100 with SMTP id fn4mr13006068oeb.67.1447646133474; Sun, 15 Nov 2015 19:55:33 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::230 X-Mailman-Approved-At: Mon, 16 Nov 2015 15:58:54 -0500 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11889 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