加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何从Bash中的返回码编号中提取位

发布时间:2020-12-15 22:17:21 所属栏目:安全 来源:网络整理
导读:我正在使用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 mess
我正在使用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

现在我需要确定Bash中是否发生了致命或错误消息.怎么做?我想我需要点操作;-)

编辑:我知道我需要按位和第三(3)进行测试并测试null以查看是否发出了致命消息或错误消息.我的问题很简单:用bash语法来做.输入是$?,ouptut又是$? (例如使用测试程序).谢谢!

解决方法

在Bash中你可以使用双括号:

#fatal error
errorcode=7
(( res = errorcode & 3 ))
[[ $res != 0 ]] && echo "Fatal Error"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读