I’m stuck on Stage Redirect stdout #jv1
Do I need to implement quoting for this to work? Idk if I messed up the order of the challenge, because it says I have to first do the redirecting.
Here are my logs:
remote: [your-program] $ ls -1 /tmp/fox > /tmp/ant/cow.md
remote: [your-program] $ cat /tmp/ant/cow.md
remote: [your-program] grape
remote: [your-program] pear
remote: [your-program] strawberry
remote: [tester::#JV1] ✓ Received redirected file content
remote: [your-program] $ echo 'Hello Emily' 1> /tmp/ant/fox.md
remote: [your-program] $ cat /tmp/ant/fox.md
remote: [your-program] 'Hello Emily'
remote: [tester::#JV1] ^ Line does not match expected value.
remote: [tester::#JV1] Expected: "Hello Emily"
remote: [tester::#JV1] Received: "'Hello Emily'"
remote: [your-program] $
remote: [tester::#JV1] Assertion failed.
remote: [tester::#JV1] Test failed
And here’s a snippet of my echo implementation:
else if(command_name == "echo"){
bool erase_one_more_space = false;
std::string temp{};
std::string message;
while (ss >> temp) {
if (temp == ">") {
std_to_file = true;
break;
}else if(temp == "1>"){
std_to_file = true;
erase_one_more_space = true;
break;
}else{
if(!message.empty()){
message += " ";
}
message += temp;
}
}
if(!std_to_file){
std::cout << command.substr(5) << '\n';
}else{
std::string std_filename;
if(ss >> std_filename){
}else{
std::cerr << "No filename provided";
continue;
}
std::ofstream file(std_filename);
file << message << '\n';
file.close();
}