lza*_*zap 5 python bash pylint
我正在使用pylint实用程序,它返回以下错误代码:
Pylint should leave with following status code:
* 0 if everything went fine
* 1 if a fatal message was issued
* 2 if an error message was issued
* 4 if a warning message was issued
* 8 if a refactor message was issued
* 16 if a convention message was issued
* 32 on usage error
status 1 to 16 will be bit-ORed so you can know which different
categories has been issued by analysing pylint output status code
Run Code Online (Sandbox Code Playgroud)
现在,我需要确定Bash中是否发生了致命或错误消息。怎么做?我想我需要这样做;-)
编辑:我知道我需要按位执行并与数字三(3)并针对null进行测试,以查看是否发出了致命消息或错误消息。我的问题很简单:使用bash语法即可。输入是$ ?,输出又是$?(例如,使用测试程序)。谢谢!
在 Bash 中你可以使用双括号:
#fatal error
errorcode=7
(( res = errorcode & 3 ))
[[ $res != 0 ]] && echo "Fatal Error"
Run Code Online (Sandbox Code Playgroud)