diff --git a/Kernel/debug/commands.c b/Kernel/debug/commands.c index 3b9abe6..458e582 100644 --- a/Kernel/debug/commands.c +++ b/Kernel/debug/commands.c @@ -282,6 +282,10 @@ void CommandDir (string argv[], int32 argc) ConsoleWrite("%#! Invalid path!\n", ColorLightRed); return; } + if ((temp->Flags & 0x7) == 0x1) { + ConsoleWrite("%#! Not a directory!\n", ColorLightRed); return; + } + // Write contents ConsoleWrite ("Content of directory %#%s:\n\n", ColorWhite, argv[1]); diff --git a/Kernel/debug/console.c b/Kernel/debug/console.c index 4d819df..5f6b4ba 100644 --- a/Kernel/debug/console.c +++ b/Kernel/debug/console.c @@ -4,7 +4,7 @@ #include "commands.c" void _process_command (string params[16], int32 count); -void _command_does_not_exist(string command); +int32 _command_does_not_exist(string command); void ConsoleMain() { @@ -57,9 +57,12 @@ void _process_command (string params[CONSOLE_MAX_PARAMS], int32 count) for (i = 0; i < ConsoleCommandsCount && Cmd == -1; i++) if (strcmp(params[0], ConsoleCommands[i]) == 0) Cmd = i; +loop: switch (Cmd) { - case -1: _command_does_not_exist(params[0]); break; + case -1: Cmd = _command_does_not_exist(params[0]); + if (Cmd != -1) goto loop; + break; case 0: CommandOsver(); break; case 1: CommandTime(); break; case 2: ConsoleClear(); break; @@ -78,18 +81,36 @@ void _process_command (string params[CONSOLE_MAX_PARAMS], int32 count) Color(0,ColorLightRed), Color(0,ColorWhite), params[0], Color(0,ColorLightRed)); break; } - } -void _command_does_not_exist(string command) +int32 _command_does_not_exist(string command) { + // Try finding a command that starts with strlen(command) letters + int32 count, i, last; + for (i = 0, count = 0; i < ConsoleCommandsCount; i++) + if (!strncmp(command, ConsoleCommands[i], strlen(command))) { ++count; last = i; } + + // Found a good command + if (count == 1) { + ConsoleWrite ("%#Did you mean %#%s%#?\n", ColorYellow, ColorWhite, ConsoleCommands[last], ColorYellow); + return last; + } + + // Shorten if too long if (strlen(command) > 20) { command[18] = command[19] = command[20] = '.'; command[21] = null; } - ConsoleWrite ("%#! Command %#%s%# does not exist!\n", - Color(0,ColorLightRed), Color(0,ColorWhite), command, Color(0,ColorLightRed)); + // Display error + ConsoleWrite ("%#! Command %#%s%# does not exist!\n", Color(0,ColorLightRed), Color(0,ColorWhite), command, Color(0,ColorLightRed)); + if (count > 0) + { + ConsoleWrite ("Available options:\n"); + for (i = 0; i < ConsoleCommandsCount; i++) + if (!strncmp(command, ConsoleCommands[i], strlen(command))) ConsoleWrite ("\t>%# %s\n", ColorYellow, ConsoleCommands[i]); + } + return -1; } diff --git a/Kernel/debug/logger.c b/Kernel/debug/logger.c index 9548277..a8f05f8 100644 --- a/Kernel/debug/logger.c +++ b/Kernel/debug/logger.c @@ -52,6 +52,8 @@ int32 LogWrite (uint8 error, string device, string format, ...) _write_char(' '); } + else return 0; + for (i = 0; i < len; i++) if (format[i] != '%' && allowed) _write_char(format[i]); else @@ -61,14 +63,14 @@ int32 LogWrite (uint8 error, string device, string format, ...) // Character case 'c': { char c = va_arg (args, char); - if (allowed) _write_char(c); + _write_char(c); break; } // String case 's': { int32* c = (int32*) va_arg (args, string); - if (allowed) _write_string((string)c); + _write_string((string)c); break; } @@ -76,10 +78,8 @@ int32 LogWrite (uint8 error, string device, string format, ...) case 'd': case 'i': { int32 c = va_arg(args, int32); char temp[32]; - if (allowed) { - ConvertIntToString(temp, c, 10); - _write_string(temp); - } + ConvertIntToString(temp, c, 10); + _write_string(temp); break; } @@ -87,20 +87,18 @@ int32 LogWrite (uint8 error, string device, string format, ...) case 'X': case 'x': { int32 c = va_arg(args, int32); char temp[32]; - if (allowed) { - ConvertUIntToString(temp, c, 16); - _write_string(temp); - } + ConvertUIntToString(temp, c, 16); + _write_string(temp); + break; } // Integers - unsigned case 'u': { int32 c = va_arg(args, uint32); char temp[32]; - if (allowed) { - ConvertUIntToString (temp, c, 10); - _write_string(temp); - } + ConvertUIntToString (temp, c, 10); + _write_string(temp); + break; } @@ -110,13 +108,13 @@ int32 LogWrite (uint8 error, string device, string format, ...) ConsoleDefaultColor = c; break; } - default: va_end(args); return 1; + case '%' : _write_char('%'); break; }; } va_end(args); - ConsoleDefaultColor = 0x7; + ConsoleDefaultColor = temp_color; ConsoleCursorUpdateHardware(); return i; } diff --git a/Kernel/include/version.h b/Kernel/include/version.h index 973f121..45df4f7 100644 --- a/Kernel/include/version.h +++ b/Kernel/include/version.h @@ -1 +1 @@ -#define OS_BUILD "0.1.0.590" +#define OS_BUILD "0.1.0.601" diff --git a/build/console.o b/build/console.o index 18418a4..68a618d 100644 Binary files a/build/console.o and b/build/console.o differ diff --git a/build/logger.o b/build/logger.o index ec5a3e0..c1f81a3 100644 Binary files a/build/logger.o and b/build/logger.o differ diff --git a/kernel.bin b/kernel.bin index 56a2997..6d57874 100644 Binary files a/kernel.bin and b/kernel.bin differ diff --git a/scripts/version.txt b/scripts/version.txt index 9706647..75a2e0d 100644 --- a/scripts/version.txt +++ b/scripts/version.txt @@ -1 +1 @@ -590 +601