Bash 循环意外结束循环且未显示原因
我有一个 bash 脚本,其代码如下:
echo "EXECUTING TASK 1"
sort -r scripts/sh/test-list | while read fn; do
sh -vx scripts/sh/test-web-task.sh "$fn"
done
echo "EXECUTING TASK 2"
sort -r scripts/sh/test-unit-list | while read fn; do
sh -vx scripts/sh/test-unit-task.sh "$fn"
done
在 test-web-task 和 test-unit-task 中,我对 grails 进行了一些调用来运行一些测试,然后执行一些打包操作。 像这样的事情:
grails test-app $1
mv results backup/$1
在文件scripts/sh/test-unit-list和scripts/sh/test-list中,我有一个要运行的测试列表。 像这样的事情:
Person
Book
第一个循环在没有运行文件 script/sh/test-list 的所有行的情况下中断,然后开始运行第二个循环。
正如您所看到的,我已将 -vx 添加到 sh 中以查看可能出现的问题。但我找不到我做错了什么。
我想也许scripts/sh/test-list 中的某些东西崩溃了,并打破了循环。如果是这种情况,我想知道是什么崩溃了,并且我希望循环继续进行而不会中断。
你能给我任何指示吗?
I have a bash script with a code like this:
echo "EXECUTING TASK 1"
sort -r scripts/sh/test-list | while read fn; do
sh -vx scripts/sh/test-web-task.sh "$fn"
done
echo "EXECUTING TASK 2"
sort -r scripts/sh/test-unit-list | while read fn; do
sh -vx scripts/sh/test-unit-task.sh "$fn"
done
In test-web-task and test-unit-task I have some calls to grails to run some tests and then do some packaging stuff.
Something like this:
grails test-app $1
mv results backup/$1
In files scripts/sh/test-unit-list and scripts/sh/test-list I have a list of tests to run.
Something like this:
Person
Book
The first loop breaks without running all the lines of the file scripts/sh/test-list and then it starts to run the second loop.
As you can see I have added -vx to sh to see what may be the problem. But I can't find what I doing wrong.
I think maybe something in scripts/sh/test-list is crashing, and breaking the loop. If this is the case I want to know what is crashing, and I want the loop to keep going without break.
Can you give me any pointer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二个脚本可能正在窃取原始脚本的标准输出和标准输入。让我知道这是否可以解决问题
The second script probably is stealing the stdout and stdin of the original script. Let me know if this fixes it