Bash while循环,如何读取输入直到条件为假 [英] Bash while loop, how to read input until a condition is false
本文介绍了Bash while循环,如何读取输入直到条件为假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直遇到运行时错误.我正在OSX的终端上运行它.错误是
I keep getting a run time error. I'm running this in a terminal on OSX. The error is,
test.sh: line 15: while[!false]: command not found
test.sh: line 16: syntax error near unexpected token `do'
test.sh: line 16: `do'
由于我刚开始编写bash脚本,因此我无法弄清楚语法上哪里出了错.
I just can't figure where I've got wrong syntactically as I'm new to writing bash scripts.
ipa build &
TASK_PID=$!
sleep 5
kill $TASK_PID
finished=false
declare -a schemes
echo "*****************************************************************************************"
echo "| View the list of available build configs above."
echo "| Enter the name of the build you want,one at a time."
echo "| Type \"done\" to finish entering scheme names"
echo "*****************************************************************************************"
while[!${finished}]
do
read input
if[$input == "done"]
then
finished=true
else
schemes=("${schemes[@]}" $input)
echo ${schemes[0]}
fi
done
echo "Do you want a verbose build? (y/n)"
read verbose
echo "Building your selected schemes....."
ipa build -s ${schemes[0]}
推荐答案
在测试条件下在方括号内留出空格
Give space around brackets in test conditions
while [ ! ${finished} ]
&
if [ $input = "done" ]
这篇关于Bash while循环,如何读取输入直到条件为假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文