【发布时间】:2023-04-11 08:42:01
【问题描述】:
好的,所以我创建了自己的 shell,并且我已经自己测试了很多,但是我需要运行和测试它的 shell 脚本。
我创建了一个包含以下内容的脚本:
#!/bin/bash
echo "ls && echo dog" | ./a.out
但是,它所做的只是无限打印命令提示符“$”,我必须强制退出程序。因此我很确定我的程序不喜欢我的脚本哈哈。我的程序通过使用 getline 来捕获用户输入,直到他们推送
string user_input;
bool good = true;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
while(good){
//command prompt
cout << "$ ";
//read in user input
getline(cin, user_input);
//tokenize user input
tokenizer tok(user_input);
//parse and execute commands inputed by user in string
//only exit while loop if user command is <exit> good = false
}
如果我正常执行程序并且我在程序中输入输入,我的 shell 就可以工作,我需要的是一个 shell 脚本,我可以使用它来为我运行和测试程序。前任。如果我在标准 linux shell 中键入 ./script.sh ,它将运行我的脚本,然后执行我的 a.out 并使用各种命令测试我自己的 shell 示例是 ls echo ...
【问题讨论】:
-
当您向我们提供零代码进行分析时,不可能分析问题并提供任何可靠的有用结果。你能提供一个Minimal, Complete, and Verifiable example吗?