这个bash语句中的想法是什么(命令|| true)?
发布时间:2020-12-15 22:39:47 所属栏目:安全 来源:网络整理
导读:我在互联网上看到了以下bash语句: PYTHON_BIN_PATH=$(which python || which python3 || true) 我明白,如果哪个python失败了,那么哪个python3会被执行,但我不明白条件结束时的真实目的.任何的想法? 解决方法 试试跑:(注意bla) which python_bla || which p
我在互联网上看到了以下bash语句:
PYTHON_BIN_PATH=$(which python || which python3 || true) 我明白,如果哪个python失败了,那么哪个python3会被执行,但我不明白条件结束时的真实目的.任何的想法? 解决方法
试试跑:(注意bla)
which python_bla || which python3_bla_bla || true echo $? 0 你会得到RC = 0.这意味着它是一个成功进入下一个命令的构造.在这里我们知道python_bla或python3_bla_bla不存在,但仍然命令给出了rc = 0 date;echo $? Thu Nov 9 01:40:44 CST 2017 0 datea;echo $? If 'datea' is not a typo you can use command-not-found to lookup the package that contains it,like this: cnf datea 127 datea||true;echo $? If 'datea' is not a typo you can use command-not-found to lookup the package that contains it,like this: cnf datea 0 注意:您还可以使用:operator而不是true来获得相同的结果.示例: command || : (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |