|
From: | Chet Ramey |
Subject: | Re: insert-last-argument doesn't work if previous cmd is a comment |
Date: | Sat, 20 Nov 2004 16:11:10 -0500 |
User-agent: | Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.7.3) Gecko/20040910 |
Nem W Schlecht wrote:
Bash Version: 3.0 Patch Level: 0 Release Status: release Description: insert-last-argument does not work if the previous command was a comment (starts with a '#'). At first, I thought this might be because I had set HISTTIMEFORMAT which inserts timestamps into the HISTFILE as a comment. However, I unset HISTTIMEFORMAT and the problem still occurs. When I attempt to do an insert-last-argument, the shell beeps. If I immediately repeat the command, the last argument from the command previous to the comment Repeat-By: Enter the following, assuming ESC-. is mapped to insert-last-argument $ echo hello $ # this is a comment $ echo <ESC-.> The shell will "beep" instead of recalling the word "comment" as it should.
The shell (really readline; this is all standard readline behavior) is behaving as designed. Readline uses the history argument extraction code to obtain the last word from the previous history entry and inserts the result. By default, the history code treats `#' as the history comment character: the character that tells it to disregard the remainder of the line. In this case, the entire line is not considered. This behavior should be documented, and I will add it to the man pages and info files. The clumsy part of this is that there's no good way to simply disable the history comment character. You can set it to a rarely-used character using an assignment to `histchars', but you can't unset it using such an assignment. Even unsetting histchars resets the history characters back to their default values. Chet
[Prev in Thread] | Current Thread | [Next in Thread] |