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: 
There are multiple ways for a program to fail. For example `grep` fails if it doesn't find the pattern looked for, or if it can't open one of the files specified.

Presently Unix allows 1 (unsigned) byte of value (the return code) to be passed back from a child to it's parent (I am ignoring the information about which signal killed a child, if a core was generated etc which could get a few more bits back).

As there are multiple ways to fail, it makes sense for there to be multiple return codes to encode these different failures, and to have one return code to indicate success.

It follows that a (`0`) is a reasonable choice to indicate success, the rest (1-255) to indicate failure (and the type of failure).

It would be perfectly possible to use 17 as meaning success, and have 0 through 16 and 18 through 255 meaning failure, but for simplicity 0 was chosen for success and 1 through 255 for the failures so there is a single range. Equally simple would have been to use 255 for success and 0 through 254 for failures. However that would limit future changes to pass back more than 8 bits and keep the simplicity of a single range of failure codes.
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.