Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

1
  • I prefer this way as well. It has the advantage that these "faux booleans" can be used in different ways with Bash. If $bool is set to either 1 or a null string, ((bool)) works just like [[ $bool ]], which is the same as [[ -n $bool ]]. To test for a false value, ((! bool)) is equal to [[ ! $bool ]]. It can even be used for parameter expansion such as echo "${bool:+This variable is true}". The values 0 and 1 do not provide this much flexibility.
    – vbwx
    Commented Mar 5 at 22:05