自动安装devstack的Bash脚本有什么问题?


1

我创建了这个bash脚本来自动安装devstack。一切正常,只有当我想退出菜单时,我才收到此错误:

./script.sh: line 12: syntax error near unexpected token ')'
./script.sh line 12: '2) exit'

这里是 ./script.sh

#!/bin/bash
clear 

echo "================="

echo "test"

echo  "================="

echo "1. test"

echo "2. exit menu"

echo -e "Maak een selectie en druk daarna op <Enter>"

read answer  

case "$answer" in

1) ./installatiedev.sh
2) exit 
esac

我希望有一个人可以帮助我。



@Rinzwind是的,这是问题,愚蠢的错误。该事件现已解决。谢谢您:)
Appollonius333 '18

Answers:


1

用两个分号(;;)终止条件1)和2 )。当找到匹配项时,将执行所有相关联的语句,直到执行双分号为止。

#!/bin/bash
clear 
echo "================="
echo "test"
echo  "================="
echo "1. test"
echo "2. exit menu"
echo -e "Maak een selectie en druk daarna op <Enter>"
read answer  
case "$answer" in
1) ./installatiedev.sh
   ;;
2) exit 
   ;;
esac
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.