Bash boolean expression and its value assignment

后端 未结 4 1778
囚心锁ツ
囚心锁ツ 2020-12-15 04:56

Is there a way to to evaluate a boolean expression and assign its value to a variable?

In most of the scripting languages there is way to evaluates e.g



        
4条回答
  •  长情又很酷
    2020-12-15 05:39

    I would suggest:

    [ "$PROCEED" = "y" ] || BOOL=1
    

    This has the advantage over checking $? that it works even when set -e is on. (See writing robust shell scripts.)

提交回复
热议问题