是否有从StringStream读取输入的正确方法

问题描述

我正在编写一个自定义bash,它以串行和并行方式执行命令。当我尝试向终端回显任何内容时,在行的末尾会有一个空格,这使我无法通过测试用例。我的过程命令方法中有错误

Commands commandProcess(std::string line,bool parallel,bool single) {
   // Create a list of commands to be returned if there
   // is processing occurring.
   Commands list; // vector of strings
   // Set up a string stream to read the line
   std::stringstream ss(line);
   std::string cl = ""; // clean line
   // While the string stream is still has unread info read
   // through quotes and assign the commands to a list.
   std::string temp = "";
   while (ss >> std::quoted(temp)) {
       cl += temp + " ";
       list.push_back(temp);
   }
   boost::trim_right(cl);
   std::cout << "Running: " << cl << std::endl;
   // Run a one line argument
   if (!parallel && single) {
       ChildProcess cp;
       cp.forkNexec(list);
       std::cout << "Exit code: " << cp.wait() << std::endl;
   }
   return list;
}

除echo命令外,所有程序在我的程序中均正常运行。任何指导都非常感激。

expectedoutput

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)