Bash boolean expression and its value assignment

You could do:

[ "$PROCEED" = "y" ] ; BOOL=$?

If you’re working with set -e, you can use instead:

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

BOOL set to zero when there is a match, to act like typical Unix return codes. Looks a bit weird.

This will not throw errors, and you’re sure $BOOL will be either 0 or 1 afterwards, whatever it contained before.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)