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.
**The origin of true = 1 and false = 0**

If you want to know the historical context of why true is 1 and false is 0 then I would like to point out that boolean algebra was "invented" by George Bool in 1847.
This was way before the first electronic computers. Boolean algebra was published in "THE MATHEMATICAL ANALYSIS OF LOGIC". You can read a copy on project gutenberg: <http://www.gutenberg.org/files/36884/36884-pdf.pdf>

I don't claim to have read it in detail, but I have skimmed enough to see that George Bool himself was using 1 as true and 0 as false.

---

**Boole's impact on computing**

Boole's algebra ("Boolean algebra") was largely ignored until it was picked up long after his death and used in computing. Even before silicon based computers, boolean algebra became useful with regard to binary electronics (as opposed to analogue). It was simple to transpose mathematical logic operators into transistor wiring (see [here](http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/trangate.html)). And from there it was simple enough to wire together multiple logic gates to represent a number in binary and [perform simple arithmetic](https://en.wikipedia.org/wiki/Adder_(electronics)).

---

With regard to "if" statements, these were derived from CPU the operation "conditional jump" where jump is known as `goto` in higher level languages.

For conditional jumps CPUs have to define a useful way to select jump or not jump. The two most common conditionals are "jump if zero" and "jump if negative" (see page 39 underlined [here](http://bitsavers.trailing-edge.com/pdf/ibm/360/asm/SC20-1646-6_int360asm_Aug70.pdf)). However the interpretation of a number as positive or negative can be subjective since the same CPU operations are used for [two's compliment](https://en.wikipedia.org/wiki/Two%27s_complement) signed integers as "unsigned" integers.

So this is all to say, the common `if` statement settled on 0 for false and 1 for true because:

* a negative / positive definition would not have worked for unsigned integers
* and 0 for true and 1 for false would have been the opposite of commonly used Boolean algebra

---

**Why is the shell different?**

The origin of the shell doing the opposite is hard to find. 0 for success certainly dates back to the 1970s and [possibly the earliest versions of unix](https://en.wikipedia.org/wiki/Unix_shell#Early_shells) (*not sure*).

*My own take on it is that a program can fully succeed in only one way but fail in many ways.*

What does seem clear is that the `true` and `false` command were designed to fit with the shell's interpretation of using a command's exit status in conditional logic:

```bash
if first_command ; then
    second_command
fi

```

If the code above is intended to mean run `second_command` if `first_command` succeeds. Then a good name for a logical placeholder that always succeeds would be `true`.