diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index cfe4f15..958144b 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 76 +#define MONTAUK_BUILD_NUMBER 79 diff --git a/programs/src/shell/tabcompletion.cpp b/programs/src/shell/tabcompletion.cpp index 522a9f8..8b220e3 100644 --- a/programs/src/shell/tabcompletion.cpp +++ b/programs/src/shell/tabcompletion.cpp @@ -26,6 +26,20 @@ bool is_executable(const char* path) { return false; } +int find_first_slash_pos(const char* string) { + int i = 0; + + while (string[i] != '\0') { + if (string[i] == '/') { + return i; + } + + i++; + } + + return -1; +} + /* i.e., "shell.elf" => "shell" */ @@ -51,19 +65,23 @@ int get_completions( // returns no. of results for (int i = 0; i < n; i++) { /* - Shift by 3 characters (names[i] + 3): - "os/shell.elf" => "shell.elf" + Shift by n characters (names[i] + n), + n = position of first slash in path + 1: + + "os/shell.elf" => "shell.elf" This is somewhat of a workaround. */ - if (montauk::starts_with(names[i] + 3, (const char*)string)) { + int inc = find_first_slash_pos(names[i]) + 1; + + if (montauk::starts_with(names[i] + inc, (const char*)string)) { if (r > arrayMax) break; if (!is_executable(names[i])) continue; - char* p = (char *)names[i] + 3; + char* p = (char *)names[i] + inc; strip_elf_extension(p); array[r] = (char *)p;