I’m stuck on Stage #(QP2) due to an error I can’t replicate happening in #(UN3).
For the command completion extension I decided to manually implement raw mode using the c-kilo text editor as reference. From there, I decided to implement the rest of the autocompletion logic as much as possible before starting the tests. I decided to do this so I could pass all the autocompletion tests at once.
However, after finishing and making sure it worked locally, I’ve noticed that while I passed the first autocompletion test (#QP2), I started to fail a prior test: #UN3.
Here are my logs:
[tester::#UN3] Running tests for Stage #UN3 (Redirection - Append stderr)
[tester::#UN3] [setup] export PATH=/tmp/blueberry/raspberry/mango:$PATH
[tester::#UN3] Running ./your_program.sh
[your-program] $ ls -1 nonexistent >> /tmp/fox/ant.md
[your-program] $ ls -1 nonexistent >> /tmp/fox/ant.md
[tester::#UN3] ^ Line does not match expected value.
[tester::#UN3] Expected: "ls: nonexistent: No such file or directory"
[tester::#UN3] Received: "$ ls -1 nonexistent >> /tmp/fox/ant.md"
[your-program]
[tester::#UN3] Test failed
However, when manually executing the shell and trying to replicate the error everything (seems to) works fine:

I’ve tried:
- Enabling debug mode.
- Disabling raw mode before execution.
- Modifying my main function in order to try to replicate the error by going from this:
int main() {
enable_raw_mode();
init_terminal();
while (!executing) {
terminal_refresh_screen();
terminal_process_keypress();
}
return 0;
}
Into this:
int main() {
int is_interactive = isatty(STDIN_FILENO);
if (is_interactive) {
enable_raw_mode();
init_terminal();
while (!executing) {
terminal_refresh_screen();
terminal_process_keypress();
}
} else {
char line[1024];
printf("Fgets\n");
while (fgets(line, sizeof(line), stdin)) {
line[strcspn(line, "\n")] = '\0';
process_command(line);
}
}
return 0;
}
And trying to run:
echo "ls -1 nonexistent >> /tmp/fox/ant.md" | ./main
But I still can’t reproduce the error:
echo "ls -1 nonexistent >> /tmp/fox/ant.md" | ./main
Fgets
ls: no se puede acceder a 'nonexistent': No existe el fichero o el directorio
I haven’t modified the code related to the redirection at all since I passed all the redirection tests. So it must be something related to the raw mode execution, but I can’t pinpoint what. If anyone could tell me how to find what the root cause is, or how to solve it, it would be very helpful.
The code related to the redirection is inside the file parser.c. While the code related to my implementation of raw_mode and the autocompletion is in the input.c file.