Bash impementation cpp "Handle invalid commands #cz2" Expected prompt ("$ ") but received ""

The task description:

In this stage, you'll implement support for printing error messages for invalid commands.

Example:

$ xyz
xyz: command not found

when implemented as show in the hint
std::getline(std::cin, input);
std::cout << input << “: command not found” << std::endl;

following test result is shown:
[tester::#FF0] Running ./your_program.sh
[your-program] $ invalid_command_1
[your-program] invalid_command_1: command not found
[tester::#FF0] Expected prompt ("$ ") but received “”
[tester::#FF0] Assertion failed.
[tester::#FF0] Test failed

so over a several attempts it turns out that expected implementation is:
std::cout << "$ ";
while(true) {
std::getline(std::cin,input);
std::cout<<cmd_str << “: command not found”<<std::endl;
std::cout << "$ ";
}

the test tries series of several consequent inputs.
So I suppose test or description should be updated.

Hey @norman-at-kbd, the stage “Handle invalid commands (#cz2)” doesn’t actually require a loop. It only needs to handle a single input.

Could you confirm if you’re actually referring to “Implement a REPL (#ff0)”, where the goal is to repeatedly read and handle commands in a loop.

@andy1li you are absolutely right, sorry for the false alarm.

1 Like

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