X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2FCLIShell_src%2Fmain.c;h=4378d1dbcb9277762356e25533fafc3555370e7f;hb=952891ddb96a341c0e24ecb7dec6361c7bbeaece;hp=579df881d8636023058b797d18b821d5a283ba93;hpb=775bf8013abe9fe4ef3d4883ea2e43bba2a84da1;p=tpg%2Facess2.git diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index 579df881..4378d1db 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -1,7 +1,7 @@ /* * AcessOS Shell Version 3 */ -#define USE_READLINE 0 +#define USE_READLINE 1 #include #include #include @@ -59,11 +59,7 @@ int main(int argc, char *argv[], char *envp[]) #if !USE_READLINE int bCached = 1; #else - tReadline readline_state = {0}; - #endif - - #if USE_READLINE - readline_state.UseHistory = 1; + tReadline *readline_state = Readline_Init(1); #endif gasEnvironment = envp; @@ -81,8 +77,7 @@ int main(int argc, char *argv[], char *envp[]) } } - write(_stdout, 22, "Acess Shell Version 3\n"); - write(_stdout, 2, "\n"); + printf("Acess Shell Version 3\n\n"); for(;;) { // Free last command & arguments @@ -92,18 +87,18 @@ int main(int argc, char *argv[], char *envp[]) bCached = 0; #endif - write(_stdout, strlen(gsCurrentDirectory), gsCurrentDirectory); - write(_stdout, 2, "$ "); + printf("%s$ ", gsCurrentDirectory); // Read Command line #if USE_READLINE - sCommandStr = Readline( &readline_state ); + sCommandStr = Readline( readline_state ); + printf("\n"); length = strlen(sCommandStr); #else sCommandStr = ReadCommandLine( &length ); if(!sCommandStr) { - write(_stdout, 25, "PANIC: Out of heap space\n"); + printf("PANIC: Out of heap space\n"); return -1; } @@ -150,6 +145,7 @@ int main(int argc, char *argv[], char *envp[]) } } +#if !USE_READLINE /** * \fn char *ReadCommandLine(int *Length) * \brief Read from the command line @@ -170,21 +166,20 @@ char *ReadCommandLine(int *Length) // Read In Command Line do { - read(_stdin, 1, &ch); // Read Character from stdin (read is a blocking call) - + ch = getchar(); // Read Character from stdin (read is a blocking call) if(ch == '\n') break; switch(ch) { // Control characters case '\x1B': - read(_stdin, 1, &ch); // Read control character + ch = getchar(); // Read control character switch(ch) { //case 'D': if(pos) pos--; break; //case 'C': if(pos