|
|
|
@ -12,6 +12,8 @@ |
|
|
|
|
#include "fstr.h" |
|
|
|
|
#include "err.h" |
|
|
|
|
|
|
|
|
|
#define S_ESCAPE 0x1 |
|
|
|
|
|
|
|
|
|
fstr_t PS1 = {0}; |
|
|
|
|
unsigned int histsize = DEF_HISTSIZE; |
|
|
|
|
|
|
|
|
@ -44,6 +46,7 @@ int main(int argc, char **argv) |
|
|
|
|
(void)argc; |
|
|
|
|
(void)argv; |
|
|
|
|
char i; |
|
|
|
|
unsigned int state = 0; |
|
|
|
|
|
|
|
|
|
sh_setup_terminal(); |
|
|
|
|
for (;;) { |
|
|
|
@ -52,12 +55,23 @@ int main(int argc, char **argv) |
|
|
|
|
sh_update_ps1(); |
|
|
|
|
sh_print_ps1(); |
|
|
|
|
fflush(stdout); |
|
|
|
|
while (1) { |
|
|
|
|
for (int line = 1; line;) { |
|
|
|
|
|
|
|
|
|
read(STDIN_FILENO, &i, 1); // This blocks
|
|
|
|
|
fputc(i, stdout); |
|
|
|
|
fflush(stdout); |
|
|
|
|
if (i == '\n') |
|
|
|
|
|
|
|
|
|
switch (i) { |
|
|
|
|
case '\n': |
|
|
|
|
line = state & S_ESCAPE; |
|
|
|
|
break; |
|
|
|
|
case '\\': |
|
|
|
|
state ^= ~S_ESCAPE; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
state &= ~S_ESCAPE; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|