Obnoxious postings from Google Groups
hansmu at xs4all.nl
Fri Nov 9 12:34:27 CET 2012
On 7/11/12 01:13:47, Steven D'Aprano wrote:
> On Tue, 06 Nov 2012 23:08:11 +0000, Prasad, Ramit wrote:
>> Steven D'Aprano wrote:
>>> On Tue, 06 Nov 2012 17:16:44 +0000, Prasad, Ramit wrote:
>>>>> To enter the newline, I typed Ctrl-Q to tell bash to treat the next
>>>>> character as a literal, and then typed Ctrl-J to get a newline.
>>>> That sounds complicated, my version of bash lets me type
>>>> 'foo<enter>bar'<enter> for the same effect.
>>> Well, I learned something new about bash.
>>> On the other hand, the Ctrl-Q next-char-is-literal trick works for
>>> entering control characters that otherwise don't have a key on the
>> Would you mind elaborating on how this works? I know it's not a bash
>> list, but I do not understand how ctrl-J is considered a literal.
>> Obviously, I must have a different definition of "literal". Where can I
>> find a list of other literals? My Google-fu is being weak today. :(
> I'm not an expert, so the following may not be exactly correct. As I
> understand it, when you hit a key on the keyboard, it sends the character
> you typed to the operating system. (The OS can then remap keys, generate
> keyboard events including a timestamp, etc.)
> Hit the J key, and the event includes character "j". Hit Shift-J, and
> character "J" is sent. Hit Ctrl-J, and the character sent is the ASCII
> control character ^J, or newline. (Technically, the name for ASCII 10 is
> "linefeed" rather than "newline".)
Actually, the correct name for this character is OS-dependant:
The ASCII standard prescribes that if an OS chooses to use a
single character as its line terminator, then it must be this
one, and one should call it "newline". Otherwise, it's name
is "linefeed". So, the correct name is "newline" on Posix
system, but "linefeed" on Windows.
> Similarly, other control character combinations send other control codes:
> ^A = ASCII 0x01 Start Of Heading
> ^L = ASCII 0xFF Formfeed \f
> ^M = ASCII 0x0D Carriage Return \r
> When readline is enabled in bash, one of the standard editing commands is
> that C-q (usually ctrl-Q on the keyboard) instructs readline to treat the
> next key as a literal. So Ctrl-Q followed by Backspace won't delete the
> previous character, but insert a literal DEL 0x7F character.
It depends on what mode bash is in. In Emacs mode, C-q works as you
describe, but in Vi mode you'd use C-v.
Doesn't everybody run bash in Vi mode :-?
> (One of those historical quirks is that on most(?) keyboards, the
> Backspace key generates a DEL character rather than the ^H backspace
> control code, and the Delete key generates an escape sequence. Go figure.)
Another quirk is that on most keyboards the "enter" key generates a
Carriage Return, which the terminal driver than converts to a Newline,
if icrlf mode is active. (Shouldn't that be called "icrnl" mode?)
Hope this helps,
More information about the Python-list