3
基于环境变量的条件分配
在bash脚本中,我要分配一个局部变量,以便该值取决于外部的全局环境变量($MYAPP_ENV)。 if [ "$MYAPP_ENV" == "PROD" ] then SERVER_LOGIN=foobar123@prod.example.com else SERVER_LOGIN=foobar987@test.example.com fi 有没有一种较短的(到目前为止还很干净)编写上述作业的方法?(大概使用某种条件运算符/内联if。)