将开关盒调到开关盒中

时间:2016-12-06 11:50:33

标签: bash

我想将开关盒调成开关盒。但我得到错误。

### User prompts
read -p "Would you like to download all source codes and build them? \"(Y|N)\" " inPut
# Get user prompt not case sensitive
case $inPut in
# First case
"y"|"Y") echo 'Starting.....'
donwload_source_code

    read -p "Would you like to start all servers? \"(Y|N)\" " inPutserver
    case $inPutserver in
    "y"|"Y") echo 'Starting.....'
    open_new_terminals_automatically $DIR "rails -s"

;;

# Second case
"n"|"N") echo 'Stopping script execution...'
exit
;;

esac

运行脚本时出错:

run.sh: line 589: syntax error: unexpected end of file

我如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您尚未终止内部case构造,该构造应如下所示。

read -p "Would you like to start all servers? \"(Y|N)\" " inPutserver
case $inPutserver in
"y"|"Y") echo 'Starting.....'
open_new_terminals_automatically $DIR "rails -s"
;;
esac      # <------ Notice the termination here.

利用http://www.shellcheck.net并从那里修复脚本中的琐碎问题。

相关问题