Repo link: https://github.com/yuriko192/codecrafters-shell-c
currently im trying to solve the challenge Builtin completion #qp2
but i kept receiving the error prompt line doesnt match expected value after tab is pressed
[tester::#QP2] Running tests for Stage #QP2 (Autocompletion - Builtin completion)
[tester::#QP2] Running ./your_program.sh
[tester::#QP2] ✓ Received prompt ($ )
[tester::#QP2] Typed "ech"
[tester::#QP2] ✓ Prompt line matches "$ ech"
[tester::#QP2] Pressed "<TAB>" (expecting autocomplete to "echo")
[your-program] $ ech
[tester::#QP2] Output does not match expected value.
[tester::#QP2] Expected: "$ echo "
[tester::#QP2] Received: "$ ech"
[tester::#QP2] Assertion failed.
[tester::#QP2] Test failed
so far, ive tried to enter rawmode to make sure the code is run on every keypress by using this logic in the file app/shell.c
void set_terminal_raw_mode() {
struct termios new_settings;
tcgetattr(STDIN_FILENO, &original_settings);
new_settings = original_settings;
new_settings.c_lflag &= ~(ICANON | ECHO);
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);
}
and ive modified my input logic to the func void get_input(char **input)
in app/main.c
my logic for initializing the autocomplete trie is in the file app/builtins.c
with the func named void initialize_autocomplete()