Reputation: 349
What is wrong with my simple if/then/else bash script?
if [ "$C" = "dev" ];then
export PREFIX=/home/bubu
export SERVER=localhost:2112
elif [ "$C" = "test" ]
export PREFIX=/server/node
export SERVER=e.foo.com:44033
else
export PREFIX=/server/node
export SERVER=f.foo.com:44033
fi
./foo.sh: line 9: syntax error near unexpected token `else'
./foo.sh: line 9: `else'
Upvotes: 1
Views: 1831
Reputation: 212288
I would suggest fixing it with a case statement:
case "$C" in
dev) export PREFIX=/home/bubu SERVER=localhost:2112;;
test) export PREFIX=/server/node SERVER=e.foo.com:44033;;
*) export PREFIX=/server/node SERVER=f.foo.com:44033;;
esac
Upvotes: 2
Reputation: 1442
A "then" is missing after elif statement:
elif [ "$C" = "test" ]; then
Upvotes: 0