- At the AGM we formed an ad-hoc documentation working group.
- One of our ideas was that we should have a last reviewed date for
documentation, so that we can periodically implement a review
mechanism (GitHub Actions posts to Slack for a regular documentation
outdatedness check?) to track how old docs are and ensure they're
still relevant.
- This is a first step towards that goal, by adding a `last_review_date`
to the metadata of all docs with a date of earlier than Homebrew's
inception because everything needs reviewing so that we start from a
good base!
In the section "Configuring Completions in `bash`", there's a line of code that sets `HOMEBREW_PREFIX` by calling `brew --prefix`, but it's done before calling `type brew` to see if brew exists. This gives a "-bash: brew: command not found" if you don't have brew installed. That line should be moved inside the `if`.
The current suggestion for users shells out to `brew --prefix` three separate times, which has a non-zero overhead (as per quick benchmark below, approx 20ms per invocation). By making a minor change, the first invocation can be stored in a local variable to reduce shell startup time.
```
$ hyperfine --warmup=3 'brew --prefix'
Benchmark #1: brew --prefix
Time (mean ± σ): 21.3 ms ± 1.5 ms [User: 8.8 ms, System: 10.6 ms]
Range (min … max): 20.3 ms … 37.0 ms 128 runs
```
When I try to run the proposed script in my `~/.bashrc` file I get this output:
```
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: have: command not found
-bash: [: =: unary operator expected
# ...
```
It goes on for quite some time and does not give me bash completion.
When I execute `source "$(brew --prefix)/etc/bash_completion"` it works and I get bash completion.
This script also emits a helpful error message letting people know if bash completion was not installed already.
I'll also add that the bash completion script takes a fairly long amount of time. I've seen between one quarter and a half of a second to execute it:
```
$ time source "$(brew --prefix)/etc/bash_completion"
real 0m0.254s
```
Though that's unrelated to this PR, making a note of it.