Bash if statement with multiple conditions throws an error

前端 未结 4 2114
慢半拍i
慢半拍i 2020-11-30 18:20

I\'m trying to write a script that will check two error flags, and in case one flag (or both) are changed it\'ll echo-- error happened. My script:

my_error_f         


        
4条回答
  •  春和景丽
    2020-11-30 18:43

    You can get some inspiration by reading an entrypoint.sh script written by the contributors from MySQL that checks whether the specified variables were set.

    As the script shows, you can pipe them with -a, e.g.:

    if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
        ...
    fi
    

提交回复
热议问题