So this is a common confusion seen in `#bash`...

`if` takes a command and switches based on its return value. `[` happens to be a command (and `[[` a built-in) which performs a test and exits successfully or not, so `if` can use that result.

Therefore, never use `[` (or `[[`) and commands together. What you did above is put the output of `command` into a string, then performed a numeric comparison using `[`. This works (in this case), but since both `which` and `command` have well-defined exit codes, that's not really what you want.

What you wanted was:

```bash
if ! which brew &>/dev/null; then
  # install brew
fi
```

But as mentioned below, using `$+command` and `(( ))` is more idiomatic zsh (and faster).