Description of problem: "fc -e echo" and "fc -e echo -1" should simply run the last command, but the latter runs the last-but-one command. Even worse,"fc -e echo xxx" reports "bash: fc: history specification out of range" when "xxx" is the last command run (provided that there is no other "xxx" in the history. Version-Release number of selected component (if applicable): bash-3.1-16.1.x86_64 How reproducible: always Steps to Reproduce: 1. run three commands, "aaa", "bbb", "ccc" (it doesn't matter that these aren't found, in fact it's safer if they're not). 2. "fc -e cat -1" should re-run the last command, ccc 3. Similarly, "fc -e cat ccc" should also re-run ccc (after re-priming the history). Actual results: (2) re-runs bbb instead of ccc (3) reports a history range out of range error Expected results: In both cases, ccc should be re-run Additional info: This bug has been around for a while and it finally annoyed me enough to track it down. I have a small shell function that runs the last command with "sudo" in front of it, viz: please () { fc -e 'sed -i "s/^/sudo /"' -1 } I discovered in the course of investigating this that missing off the "-1" results in a working function. The attached patch (which can also be found at http://lists.gnu.org/archive/html/bug-bash/2008-03/msg00035.html) fixes the problem by the call to delete_last_history() _after_ the block that calculates histbeg and histend. The default cases (where the history number is not specified) are unaffected by this move. This bug has been around for quite some time, probably since this change: q. The `fc' builtin now removes the `fc' command that caused it to invoke an editor on specified history entries from the history entirely, rather than simply ignoring it.
Created attachment 299041 [details] Proposed patch
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2009-0116.html