Stuck on #QP2, program fails for tester #UN3

Hi everyone,

I’m currently working on the Autocompletion stage of the Build your own Shell challenge in C++. Instead of the recommended readline library, I decided to use the linenoise library (integrated directly into my vendor directory).

After implementing the completion logic and switching my input handling to use linenoise(), I encountered a strange issue where the CodeCrafters tester receives empty strings (or just whitespace) instead of my program’s output.

Crucially, this issue is a regression affecting previous stages. Tests that used to pass (like Stage #CZ2: Invalid Commands) are now failing on the server, even though they still work perfectly in my local environment.

Here is the failure log from the server (Stage #CZ2):

[tester::#CZ2] Running tests for Stage #CZ2 (Handle invalid commands)
[tester::#CZ2] Running ./your_program.sh
[your-program] $ invalid_mango_command
[your-program]                        
[tester::#CZ2] ^ Line does not match expected value.
[tester::#CZ2] Expected: "invalid_mango_command: command not found"
[tester::#CZ2] Received: "                       "
[tester::#CZ2] Assertion failed.
[tester::#CZ2] Test failed

My Code Context:

My full code is available on GitHub (since it’s a bit too much to paste here):
Millenarysnow/codecrafters-shell-cpp

Briefly, I am capturing input like this:

void MyShell::Shell::input()
{
    // ... setup ...
    char* line = linenoise("$ ");
    if (line == nullptr) return;
    Input = string(line);
    free(line);
    // ... processing ...
}

It seems like linenoise might be interfering with the output buffering or the terminal state (Raw mode vs. Cooked mode) in the test environment, causing the output stdout/stderr to be lost or not captured by the tester.

Has anyone ran into similar issues with linenoise on this platform? Is there a specific way to ensure the terminal state is flushed or reset correctly before printing results?

Any help would be appreciated!