Question: I started a shell for another user on my system. However there's no systemd user instance for that user:

```
helloer@host $ sudo -u testusr bash
testusr@host $ systemctl --user status
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)

```

How can I start a dbus or systemd user instance for testusr?

I'm running Arch Linux, linux 5.11.8.arch1-1, dbus 1.12.20-1, systemd 247.4-2.

Answer: 
You are comparing apples to pears. They taste different. :-)

Arithmetic
==========

An **arithmetic** `0` means false[a] both in c and the shell:

```
$ if ((0)); then echo true; else echo false; fi
false

```

Or, in a more portable test, but somewhat more convoluted:

```
$ echo $(( 22 == 23 ))
0

```

[a] Actually, what is being written is an ASCII character (`0`) (ASCII in most systems, but may be others) with the decimal byte value of `48` which is transparently being converted to a byte value of `0` (A `c char` of value `0`). And is this byte value of `0` that is taken to mean false **in c**

That is so for most shells as the arithmetic expansion is actually a direct copy of the c arithmetic. No differences should exist there.

Exit status
===========

But the exit status (`$?`) of an utility is something different:

```
$ echo "$(( 22 == 23 )) $? -- $((22 == 22 )) $?"
0 0 -- 1 0

```

Theory
======

I can only offer my opinion to the reason of why this is so.

In [classical logic](https://en.wikipedia.org/wiki/Classical_logic), with its intended semantics, [the truth values are true (denoted by 1 or the *verum* **⊤**), and untrue or false (denoted by 0 or the *falsum* **⊥**)](https://en.wikipedia.org/wiki/Truth_value#Classical_logic)

[Propositional Logic Truth Table](https://dyclassroom.com/boolean-algebra/propositional-logic-truth-table): We denote the value true as 1 and value false as 0.

That is just a codification of the human way of thinking that `nothing/empty` is closer to `false`.

That description got [encoded in the c language](https://stackoverflow.com/questions/37291681/does-the-c-standard-explicitly-indicate-truth-value-as-0-or-1)

But having only one value (`0`) for an exit status of error seemed too constricting, the logic got reversed, and the (`0`) was changed to **success**, leaving many more codes for the several possible reasons of error. That is how it is used in the shell.
You are confusing two different things:

1. Integers as used as boolean.

A boolean is a response to a question: "Is this variable's value the same as this other variable's value?" The answer is a *false* or a *true*. These could be encoded as 0 or 1.
2. Integers as used as exit-status.

An exit-status is a statement of fact: "The utility terminated after successfully doing what it was asked to do.", "The utility encountered a particular error condition and failed." The exit-status could be encoded as any integer between 0 and 127, where zero signifies *success* or *no error*.

These are *similar*, but only because both use integers as a way of encoding *true* and *false* (booleans), or *successful* and *unsuccessful* (exit status). Other things that use integers are the number of centimeters an athlete can jump, and the ranking associated with that athlete based on that jump, but we rarely confuse these.

In the C language, `if` statements act directly on the result of the arithmetic evaluation of the given expression. Since the shell has always been geared towards execution of programs and handling of job pipelines etc., an `if` statement in the shell is *made for* determining whether a utility successfully ran or not. This involves examining the exit-status of the utility that it ran.

An exit-status is *zero* if the utility finished successfully. You get a boolean when you ask "Is the exit-status zero?", which is what the `if` statement in the shell is doing (`if utility; then echo ok; else not ok; fi`). If the utility wasn't successful, you'll get a *false* back from that test, and you may then start looking at the exit-status and the utility's diagnostic output to try to figure out what went wrong.

The exit-status may encode the specific reason the utility terminated unsuccessfully, a bit like library functions and system calls in C often sets an "`errno` status code" that encode similar information to the caller (see `man errno` and, as an example, the `RETURN VALUE` and `ERRORS` sections of `stat(2)` with `man 2 stat`).

The `false` utility does nothing, unsuccessfully. You can see that it fails because it sets a non-zero exit status:

```bsh
$ false; echo "$?"
1

```

This `1` is not a boolean. It's a non-zero exit-status signifying failure.

If you want to do boolean logic in the shell, use `$(( ... ))` to evaluate your expression, and the `test` utility for comparing:

```
if [ "$(( a == 12 ))" -ne 0 ]; then
    echo 'a is 12'
fi

```

In this example, the value `$a` is compared as an integer against 12. If `$a` is 12, the arithmetic expansion would expand to `1`, otherwise to `0`. *These are boolean values*.

The *exit-status* of `[ "$(( a == 12 ))" -ne 0 ]` would be zero if `$a` was 12, causing the `echo` to be executed, or non-zero if `$a` wasn't 12, causing the `echo` to be skipped.

For utilities with more interesting exit-statuses than just 0 and 1, see e.g. the `curl` manual (the `EXIT CODES` section towards the end), and the `rsync` manual (the `EXIT VALUES` section towards the end).