how command is repeated in terminals in bash shell
I am on the process of making a shell . It has some functionalities and a little bit of signal handling. Now I want to know how in bash shell commands are repeated using an arrow key(u can see the previous command when u press the up arrow).Can anyone give me some idea?
|
Well I thought my post needed a revision. Consider the following code fragment:
#include <stdio.h> #include <stdlib.h> int main(){ char c = getchar(); printf("%c\t%d\n",c,c); return 0; } Whenever I run this program the character I press a key to get a character. that character is echoed on terminal.Then again the char and its ascii value is printed.All I want is that the character is not echoed on the screen when I press it.For example with char 'a' I get printed: a a 97 but I want 'a 97' only.Is there a way of doing that? Another thing,consider the same program with input of 'up arrow key'(not the string,for sure).It prints on terminal : ^[[A > 27 = '> ='(character is not entirely like that,but copying from terminal doesnot put the correct character) Does some keys in the keyboard are handled some other way? |
This fits better in the programming section.
You have to switch your terminal to raw mode; see man termios (function cfmakeraw()). Further, when you press some keys (like arrows, home etc), multiple characters are placed in the input buffer. |
hello Wim Sturkenboom. I've been thinking this for a while but does this mean that bash always receive encoded characters and no more raw input? I mean no more scan codes or the likes?
|
I think it does although I'm not sure.
|
All times are GMT -5. The time now is 09:30 AM. |