472 Commits

Author SHA1 Message Date
Greg NISBET
077eee8f86 [shell] Override CDPATH in brew script.
The CDPATH environment variable can affect the behavior of
`cd`, and `cd` takes the `-P`, `-L` and `-e` flags.
(I didn't know about `-e` until looking at the source)
Make quietcd more robust by setting the CDPATH to ''.

I tested this change by running the following commands from a nonstandard
directory, which caused some of tcsh's and perl's dependencies to be recompiled.

$ [path to brew] install tcsh
$ [path to brew] install perl

Here's a link to the source code of `cd` in a mirror of the bash repo.

ec8113b986/builtins/cd.def (L267)
2023-11-04 16:21:31 -07:00
Mike McQuaid
729a6d4eac
Merge pull request #16064 from thecaralice/term-env
Add a few environment variables important for editors
2023-10-30 14:40:56 +00:00
Alice Carroll
9378b12d26
Re-export COLORTERM only locally in brew edit 2023-10-30 00:01:51 +03:00
apainintheneck
e1dda872c3 use XDG_CACHE_HOME on Linux
This variable was getting filtered out before so it wasn't possible
for us to use it as the default for HOMEBREW_DEFAULT_CACHE
and HOMEBREW_DEFAULT_LOGS.
2023-10-28 19:10:20 -07:00
Alice Carroll
5bd9fe7303
Add a few environment variables important for editors 2023-09-30 05:51:36 +03:00
Mike McQuaid
d43e1d0d83
bin/brew: pass through some SSH/sudo env vars.
`HOMEBREW_SSH_TTY` and `HOMEBREW_SUDO_USER` will be needed for
`brew services` after
https://github.com/Homebrew/homebrew-services/pull/588 is merged.
2023-09-27 11:59:28 +01:00
Mike McQuaid
4184546067
bin/brew: require HOME to be set.
Rather than having increasingly involved workarounds that require
other variables to be set.

Closes #15822
2023-08-05 13:41:50 +01:00
Carlo Cabrera
bcbb969796
bin/brew: avoid eval and grep
`eval` is a much bigger hammer than we need here, so let's try to avoid
that.

Also, we can use the builtin `read` instead of shelling out to `grep`
which will be slightly more efficient.
2023-08-04 22:00:46 +08:00
Mike McQuaid
59ea118991
bin/brew: handle missing $HOME.
Try to build it using `$USER` or `$LOGNAME` and, if both are missing,
just give up.
2023-08-04 08:30:37 +01:00
Mike McQuaid
375a7ee8dc
Allow configuring Homebrew with .env files
For a long time people have requested some sort of configuration files
for Homebrew. Now: here's the first version of that.

Similarly to how you can configure Git for a system, a repository or
a user: you can configure Homebrew for a system, a prefix or a user.

The system-wide configuration file is `/etc/homebrew/brew.env`, the
prefix-specific configuration file is
`$HOMEBREW_PREFIX/etc/homebrew/brew.env`
and the user-specific configuration file is `~/.homebrew/brew.env`.

As we need to read these files from Bash in `bin/brew` (so they can)
influence functionality ASAP: they are in a simple format that Bash
can read. It may be that we have more complex array or hash data in
future that's configured through JSON or YAML (most likely JSON as we
use it more) and stored in a `brew.json`/`brew.yaml` file in the same
directory.

As this is relying on `eval` in Bash which is fairly dangerous: we
filter the lines with a regex to ensure we're only permitting setting
`HOMEBREW_*` variables and nothing more.

To give a bit of power to system administrators, the
`HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY` variable can be set in
`/etc/homebrew/brew.env` to ensure that the system-wide configuration
file is loaded last and overrides any prefix or user settings.

Now that we have an actual location for configuration files, let's also
change the `brew livecheck` watchlist configuration file to be in this
directory and deprecate the existing location. As this is a developer
command and the mitigation is to just move the file: we don't need to
follow the normal deprecation process here.
2023-07-28 17:17:14 +01:00
Bo Anderson
623eeb4e47
cmd/update-report: tweak messages for CI 2023-07-07 21:10:21 +01:00
Patrick Linnane
a7e23a27ae
bin/brew: remove HOMEBREW_NO_ENV_FILTERING error 2023-06-25 11:47:42 -07:00
Mike McQuaid
e6a006ee6b
Revert "Guard GITHUB_* variables by GITHUB_ACTIONS." 2023-05-24 12:49:27 +01:00
Markus Reiter
f320139fca
Guard GITHUB_* variables by GITHUB_ACTIONS. 2023-05-19 19:56:02 +02:00
Carlo Cabrera
b65f08700d
bin/brew: add all GITHUB_* vars to env allowlist
See #15441.
2023-05-17 19:53:46 +08:00
Carlo Cabrera
da0cd37bd4
brew/brew: add GITHUB_EVENT_PATH to env allowlist
Needed for Homebrew/homebrew-test-bot#922.
2023-05-17 01:41:58 +08:00
William Woodruff
ce7283ac32
brew: add GITHUB_STEP_SUMMARY to allowlist
Signed-off-by: William Woodruff <william@yossarian.net>
2023-05-02 19:24:14 -04:00
Carlo Cabrera
de95396407
brew: don't filter GITHUB_EVENT_NAME
We need this in `test-bot`. See Homebrew/homebrew-test-bot#905 and
Homebrew/homebrew-test-bot#906.
2023-04-14 20:40:14 +08:00
Carlo Cabrera
6f63be411b
bin/brew: refine generation of HOMEBREW_* env vars
We inherit some variables from the user's environment but prefix them
with `HOMEBREW_`. This is the case for (1) variables documented in the
manpage and also for some (2) variables used internally by `brew`.

We currently treat both types identically, but we should not. In
particular, we allow users to override type (1), but we don't want to do
this for type (2).

This was partially fixed in f4103e5d61526cfbf7f31540ba45ec171adc452e,
but that fix did not go far enough. Some variables that the user should
not be allowed to override can still be overridden.

This change completes the partial fix and refactors the code so that
we're less likely to mistakenly conflate the two types of variables in
the future.
2023-02-15 13:27:02 +08:00
Daniel Bayley
2ff90c3232 Fix HOMEBREW_BAT_CONFIG_PATH hint
`HOMEBREW_BAT_CONFIG_PATH` should respect [`BAT_CONFIG_PATH`](https://github.com/sharkdp/bat#configuration-file), in the same way that `HOMEBREW_BAT_THEME` [reflects](https://github.com/Homebrew/brew/pull/13385/files#diff-a8ebbe0466e56bdb9c7ebc74d5ffbd383b8c0902fcb5146cb1960e3d69dadeb1R78) `BAT_THEME`.

Previous, for context:
https://github.com/Homebrew/brew/pull/7488
https://github.com/Homebrew/brew/pull/11975
https://github.com/Homebrew/brew/pull/13385
2023-02-09 19:24:31 +00:00
Mike McQuaid
4c95e0dc3f
Merge pull request #14181 from kaihowl/fix/nounset
fix: allow running bin/brew with SHELLOPTS=nounset
2022-11-29 11:14:44 +00:00
Kai Hoewelmeyer
3e0bb17780 please shellcheck 2022-11-28 19:54:30 +01:00
Kai Hoewelmeyer
a5b29a79e6 and another one 2022-11-28 19:36:03 +01:00
Kai Hoewelmeyer
43c3c59ca4 fix one more 2022-11-28 19:34:20 +01:00
Kai Hoewelmeyer
4d4f476f73 set -u and fix follow up errors 2022-11-28 19:31:28 +01:00
Shivam Mathur
27dd46d6a9 bin/brew: add GITHUB_OUTPUT 2022-11-27 09:06:56 +00:00
Kai Hoewelmeyer
5db5c6e99a fix: allow running bin/brew with SHELLOPTS=nounset
A similar fix is already present on line 6.
2022-11-26 17:41:36 +01:00
Mike McQuaid
2961132e01
tests: fix under GitHub Codespaces. 2022-11-03 16:33:04 +00:00
Mike McQuaid
3fcd62238a
Merge pull request #13595 from MikeMcQuaid/no_homebrew_no_env_filtering
bin/brew: remove HOMEBREW_NO_ENV_FILTERING.
2022-08-23 11:21:30 +01:00
Martijn Pieters
e3a67d2220 brew: add XDG_RUNTIME_DIR copy
Further support for brew services; `systemctl --user` falls back to
XDG_RUNTIME_DIR if no DBUS daemon is available.
2022-08-11 21:00:38 +01:00
Mike McQuaid
0f54f342e6
bin/brew: remove HOMEBREW_NO_ENV_FILTERING.
It's been deprecated for a long time. Add a disabling message to be
nice (that we'll remove in future).
2022-07-22 14:39:21 +01:00
Bo Anderson
fad20859b1
Merge pull request #13594 from MikeMcQuaid/remove_github_actions_homebrew_macos_self_hosted
bin/brew: remove GITHUB_ACTIONS_HOMEBREW_MACOS_SELF_HOSTED.
2022-07-22 14:23:15 +01:00
Mike McQuaid
f4103e5d61
bin/brew: never use HOMEBREW_PATH from users.
Fixes https://github.com/Homebrew/brew/issues/13548
2022-07-22 10:33:43 +01:00
Mike McQuaid
25364cbe62
bin/brew: remove GITHUB_ACTIONS_HOMEBREW_MACOS_SELF_HOSTED.
It has been more than a few days.
2022-07-22 10:31:10 +01:00
danielnachun
5a711decff
bin/brew: add GITHUB_RUN_ATTEMPT 2022-07-21 16:02:04 -07:00
Kid
721a27d68d dev-cmd/cat: support setting bat theme via environment variable 2022-06-06 08:44:47 +08:00
Carlo Cabrera
f88e376a98
Avoid filtering TERMINFO_DIRS
Closes #13248.
2022-05-12 16:03:35 +08:00
Bo Anderson
97b94a78b4
bin/brew: allow GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED 2021-12-13 23:05:32 +00:00
XuehaiPan
cf7def0c68
style: apply shellcheck autofix 2021-11-08 03:07:25 +00:00
XuehaiPan
1be5e97e82 brew: fail fast when not using bash 2021-09-16 21:20:57 +08:00
XuehaiPan
bd8db0737d style: fix inconsistent code style for shell scripts 2021-09-16 01:06:19 +08:00
XuehaiPan
c2d5d84b21 Merge remote-tracking branch 'upstream/master' into fix-inconsistent-shell-style 2021-09-16 01:01:49 +08:00
XuehaiPan
954c3596b2 brew: fail fast when not using bash 2021-09-15 17:10:05 +08:00
XuehaiPan
baac35785c style: do not allow multi-line for statements 2021-09-15 15:00:23 +08:00
XuehaiPan
3f96d963f7 style: fix inconsistent code style for shell scripts 2021-09-15 14:59:01 +08:00
Bo Anderson
a84b13b6e9
bin/brew: actually quiet cd
Fixes #11886.
2021-08-19 13:33:31 +01:00
Sean Molenaar
e660766514
brew: add DBUS_SESSION_BUS_ADDRESS copy 2021-07-08 10:28:48 +02:00
Dawid Dziurla
ce436791c9
brew: pass GITHUB_ACTIONS_HOMEBREW_MACOS_SELF_HOSTED 2021-06-28 10:50:08 +02:00
Carlo Cabrera
4fb06efe81
Fix TMUX env variable filtering
We currently filter out `TMUX`, but this breaks displaying some caveats.
This also enables an alias I use (and improved by @Rylan12):

    brew alias fzp='!id="$(gh pr list -L200 -R github.com/Homebrew/homebrew-core | TMUX=$HOMEBREW_TMUX fzf-tmux -p "90%,50%" --multi | cut -f1)"; [ -n "$id" ] && brew pr-publish --autosquash $id'
2021-05-13 17:05:18 +01:00
Mike McQuaid
7af68d0f8e
Fix shellcheck failures
A new version of `shellcheck` (I think?) brought us so new warnings and
errors.

To fix:
- pass `--source-path` so we don't need to stop `shellcheck` trying to
  read sourced files every time
- disable some more warnings/errors we don't care about fixing
2021-04-22 13:18:44 +01:00