在我的shell脚本中,我启动了一个程序,该程序包含一个死循环,并且在每一轮中都要求用户输入一些信息。代码片段如下所示:
while (1) {
cout << "Please input a number:\n";
cin >> num;
}现在,我有一个测试文件test.txt:
1
2
3我的shell脚本是这样的:
while read input
do
echo "$input" | ./a
done < "$1"
... #some other logic in the shell script$1是test.txt。我想知道在测试完所有测试用例之后,如何继续执行shell脚本中的其他逻辑?现在,当我运行shell脚本时,它是一个死循环。谢谢!!
发布于 2014-09-15 06:23:33
你需要修复你的死循环。
演示,带bash。
./a脚本
while :
do
read -r -p 'Please a number:' num
echo "got: $num"
done将真正在死循环中运行-没有结尾
如果您尝试下一个./a
while read -r -p 'Please a number:' num
do
echo "got: $num"
done将打印:
got: 1
got: 2
got: 3https://stackoverflow.com/questions/25838419
复制相似问题