Linking macOS-provided software breaks things only in `/usr/local`
prefixes, hence the `default_prefix?` check, which was included when our
only default prefix on macOS was `/usr/local`. Now that we install into
`/opt/homebrew` too, the default prefix check is needlessly restrictive.
The way we currently handle @-versioned formulae linking is pretty
labourius:
- it requires extensive use of `link_overwrite` to avoid the `link`
stage failing on certain install/upgrade scenarios
- we teach people to use `brew link --force` whenever they wish to
link a versioned formulae when it's pretty obvious what's expected
in that situation
Instead, let's:
- automatically unlink other versioned formulae when linking a
versioned formula (either through `brew link` or `install`/`upgrade`
/`reinstall`)
- notify the user what we've done (with the same messaging as if
they had run `brew link` manually)
We've not seen complaints about these and they are the default behaviour
on High Sierra and Mojave so it's easier to apply them consistently
everywhere.
The change in #4441 broke the handling of the `elsif`s due to the
change in logic. As every block here has a `next` there's no need to do
an `elsif` in here at all. Additionally, reorder the conditions in here
so you get an appropriate message depending on what you're trying to do.
Finally, tweak some of the messaging to remove things that are ignored
and tell people correct commands to run to link things.
People are getting in the habit of force-linking things like `zlib` to
fix linking/include issues on Mojave (which doesn't install headers to
`/usr/include` by default). This way lies madness so encourage people to
instead pass the correct compiler flags instead.