How to ignore return value different then 0 when I have set -e?

前端 未结 2 1471
广开言路
广开言路 2021-01-11 16:15

I often add set -e in my bash scripts. However this time I have to call a command that returns some meaningless number instead of 0 on success. How can I tell b

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-11 16:59

    true always returns a zero exit code. So you can do

    command-with-meaningless-return-value || true
    

提交回复
热议问题