(C) QP2 - How to modify prompt line

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()

Hey @yuriko192, looks like you’ve got past this stage. Do you happen to remember what was wrong? Would love to see if we can improve the tester / instructions.

nope, still stuck @andy1li i past the stage by trying another language

Hey @yuriko192, sorry for the delayed response!

The issue was due to your repo using an older Alpine-based buildpack. I’ve upgraded it to the latest version and pushed a commit to your repo. You can run git pull to get the latest changes.

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.