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: 
**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`.
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).