Skip to content

Commit e21cbd6

Browse files
authored
Merge pull request #19153 from Homebrew/env_var_consistency
Use environment variables consistently
2 parents 9fd2b27 + bbf5a9f commit e21cbd6

24 files changed

+384
-369
lines changed

Library/Homebrew/cask/config.rb

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ class Config
1616
{
1717
appdir: "/Applications",
1818
keyboard_layoutdir: "/Library/Keyboard Layouts",
19-
colorpickerdir: "~/Library/ColorPickers",
20-
prefpanedir: "~/Library/PreferencePanes",
21-
qlplugindir: "~/Library/QuickLook",
22-
mdimporterdir: "~/Library/Spotlight",
23-
dictionarydir: "~/Library/Dictionaries",
24-
fontdir: "~/Library/Fonts",
25-
servicedir: "~/Library/Services",
26-
input_methoddir: "~/Library/Input Methods",
27-
internet_plugindir: "~/Library/Internet Plug-Ins",
28-
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
29-
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
30-
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
31-
screen_saverdir: "~/Library/Screen Savers",
19+
colorpickerdir: "${HOME}/Library/ColorPickers",
20+
prefpanedir: "${HOME}/Library/PreferencePanes",
21+
qlplugindir: "${HOME}/Library/QuickLook",
22+
mdimporterdir: "${HOME}/Library/Spotlight",
23+
dictionarydir: "${HOME}/Library/Dictionaries",
24+
fontdir: "${HOME}/Library/Fonts",
25+
servicedir: "${HOME}/Library/Services",
26+
input_methoddir: "${HOME}/Library/Input Methods",
27+
internet_plugindir: "${HOME}/Library/Internet Plug-Ins",
28+
audio_unit_plugindir: "${HOME}/Library/Audio/Plug-Ins/Components",
29+
vst_plugindir: "${HOME}/Library/Audio/Plug-Ins/VST",
30+
vst3_plugindir: "${HOME}/Library/Audio/Plug-Ins/VST3",
31+
screen_saverdir: "${HOME}/Library/Screen Savers",
3232
}.freeze,
3333
T::Hash[Symbol, String],
3434
)

Library/Homebrew/cmd/--cache.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def self.command_name = "--cache"
1515

1616
cmd_args do
1717
description <<~EOS
18-
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
18+
Display Homebrew's download cache. See also `$HOMEBREW_CACHE`.
1919
2020
If a <formula> or <cask> is provided, display the file or directory used to cache it.
2121
EOS

Library/Homebrew/cmd/cleanup.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CleanupCmd < AbstractCommand
1313
Remove stale lock files and outdated downloads for all formulae and casks,
1414
and remove old versions of installed formulae. If arguments are specified,
1515
only do this for the given formulae and casks. Removes all downloads more than
16-
#{days} days old. This can be adjusted with `HOMEBREW_CLEANUP_MAX_AGE_DAYS`.
16+
#{days} days old. This can be adjusted with `$HOMEBREW_CLEANUP_MAX_AGE_DAYS`.
1717
EOS
1818
flag "--prune=",
1919
description: "Remove all cache files older than specified <days>. " \

Library/Homebrew/cmd/desc.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Desc < AbstractCommand
2525
"it is interpreted as a regular expression."
2626
switch "--eval-all",
2727
description: "Evaluate all available formulae and casks, whether installed or not, to search their " \
28-
"descriptions. Implied if `HOMEBREW_EVAL_ALL` is set."
28+
"descriptions. Implied if `$HOMEBREW_EVAL_ALL` is set."
2929
switch "--formula", "--formulae",
3030
description: "Treat all named arguments as formulae."
3131
switch "--cask", "--casks",
@@ -48,7 +48,7 @@ def run
4848

4949
if search_type.present?
5050
if !args.eval_all? && !Homebrew::EnvConfig.eval_all? && Homebrew::EnvConfig.no_install_from_api?
51-
raise UsageError, "`brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
51+
raise UsageError, "`brew desc --search` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!"
5252
end
5353

5454
query = args.named.join(" ")

Library/Homebrew/cmd/info.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Info < AbstractCommand
2727
EOS
2828
switch "--analytics",
2929
description: "List global Homebrew analytics data or, if specified, installation and " \
30-
"build error data for <formula> (provided neither `HOMEBREW_NO_ANALYTICS` " \
31-
"nor `HOMEBREW_NO_GITHUB_API` are set)."
30+
"build error data for <formula> (provided neither `$HOMEBREW_NO_ANALYTICS` " \
31+
"nor `$HOMEBREW_NO_GITHUB_API` are set)."
3232
flag "--days=",
3333
depends_on: "--analytics",
3434
description: "How many days of analytics data to retrieve. " \
@@ -57,7 +57,7 @@ class Info < AbstractCommand
5757
switch "--eval-all",
5858
depends_on: "--json",
5959
description: "Evaluate all available formulae and casks, whether installed or not, to print their " \
60-
"JSON. Implied if `HOMEBREW_EVAL_ALL` is set."
60+
"JSON. Implied if `$HOMEBREW_EVAL_ALL` is set."
6161
switch "--variations",
6262
depends_on: "--json",
6363
description: "Include the variations hash in each formula's JSON output."

Library/Homebrew/cmd/install.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class InstallCmd < AbstractCommand
2020
Install a <formula> or <cask>. Additional options specific to a <formula> may be
2121
appended to the command.
2222
23-
Unless `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
23+
Unless `$HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
2424
outdated dependents and dependents with broken linkage, respectively.
2525
26-
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for
26+
Unless `$HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for
2727
the installed formulae or, every 30 days, for all formulae.
2828
29-
Unless `HOMEBREW_NO_INSTALL_UPGRADE` is set, `brew install` <formula> will upgrade <formula> if it
29+
Unless `$HOMEBREW_NO_INSTALL_UPGRADE` is set, `brew install` <formula> will upgrade <formula> if it
3030
is already installed but outdated.
3131
EOS
3232
switch "-d", "--debug",

Library/Homebrew/cmd/nodenv-sync.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Cmd
99
class NodenvSync < AbstractCommand
1010
cmd_args do
1111
description <<~EOS
12-
Create symlinks for Homebrew's installed NodeJS versions in `~/.nodenv/versions`.
12+
Create symlinks for Homebrew's installed NodeJS versions in `${HOME}/.nodenv/versions`.
1313
1414
Note that older version symlinks will also be created so e.g. NodeJS 19.1.0 will
1515
also be symlinked to 19.0.0.

Library/Homebrew/cmd/pyenv-sync.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Cmd
99
class PyenvSync < AbstractCommand
1010
cmd_args do
1111
description <<~EOS
12-
Create symlinks for Homebrew's installed Python versions in `~/.pyenv/versions`.
12+
Create symlinks for Homebrew's installed Python versions in `${HOME}/.pyenv/versions`.
1313
1414
Note that older patch version symlinks will be created and linked to the minor
1515
version so e.g. Python 3.11.0 will also be symlinked to 3.11.3.

Library/Homebrew/cmd/rbenv-sync.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Cmd
99
class RbenvSync < AbstractCommand
1010
cmd_args do
1111
description <<~EOS
12-
Create symlinks for Homebrew's installed Ruby versions in `~/.rbenv/versions`.
12+
Create symlinks for Homebrew's installed Ruby versions in `${HOME}/.rbenv/versions`.
1313
1414
Note that older version symlinks will also be created so e.g. Ruby 3.2.1 will
1515
also be symlinked to 3.2.0.

Library/Homebrew/cmd/readall.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ReadallCmd < AbstractCommand
2525
description: "Syntax-check all of Homebrew's Ruby files (if no <tap> is passed)."
2626
switch "--eval-all",
2727
description: "Evaluate all available formulae and casks, whether installed or not. " \
28-
"Implied if `HOMEBREW_EVAL_ALL` is set."
28+
"Implied if `$HOMEBREW_EVAL_ALL` is set."
2929
switch "--no-simulate",
3030
description: "Don't simulate other system configurations when checking formulae and casks."
3131

@@ -50,7 +50,7 @@ def run
5050

5151
taps = if args.no_named?
5252
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
53-
raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
53+
raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!"
5454
end
5555

5656
Tap.installed

Library/Homebrew/cmd/reinstall.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class Reinstall < AbstractCommand
2222
Uninstall and then reinstall a <formula> or <cask> using the same options it was
2323
originally installed with, plus any appended options specific to a <formula>.
2424
25-
Unless `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
25+
Unless `$HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
2626
outdated dependents and dependents with broken linkage, respectively.
2727
28-
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
28+
Unless `$HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
2929
reinstalled formulae or, every 30 days, for all formulae.
3030
EOS
3131
switch "-d", "--debug",

Library/Homebrew/cmd/search.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SearchCmd < AbstractCommand
4040
switch "--eval-all",
4141
depends_on: "--desc",
4242
description: "Evaluate all available formulae and casks, whether installed or not, to search their " \
43-
"descriptions. Implied if `HOMEBREW_EVAL_ALL` is set."
43+
"descriptions. Implied if `$HOMEBREW_EVAL_ALL` is set."
4444
switch "--pull-request",
4545
description: "Search for GitHub pull requests containing <text>."
4646
switch "--open",
@@ -71,7 +71,7 @@ def run
7171

7272
if args.desc?
7373
if !args.eval_all? && !Homebrew::EnvConfig.eval_all? && Homebrew::EnvConfig.no_install_from_api?
74-
raise UsageError, "`brew search --desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
74+
raise UsageError, "`brew search --desc` needs `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!"
7575
end
7676

7777
Search.search_descriptions(string_or_regex, args)

Library/Homebrew/cmd/shellenv.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ class Shellenv < AbstractCommand
1515
1616
Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
1717
18-
The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times.
19-
To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second
20-
respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.bash_profile` or
21-
`~/.zprofile` on macOS and `~/.bashrc` or `~/.zshrc` on Linux) with: `eval "$(brew shellenv)"`
18+
The variables `$HOMEBREW_PREFIX`, `$HOMEBREW_CELLAR` and `$HOMEBREW_REPOSITORY` are also exported to avoid
19+
querying them multiple times.
20+
To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories
21+
are first and second respectively in your `PATH`. Consider adding evaluation of this command's output to
22+
your dotfiles (e.g. `${HOME}/.bash_profile` or `${HOME}/.zprofile` on macOS and `${HOME}/.bashrc` or
23+
`${HOME}/.zshrc` on Linux) with: `eval "$(brew shellenv)"`
2224
23-
The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports.
25+
The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output
26+
POSIX exports.
2427
EOS
2528
named_args :shell
2629
end

Library/Homebrew/cmd/tap.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TapCmd < AbstractCommand
4141
description: "Migrate tapped formulae from symlink-based to directory-based structure."
4242
switch "--eval-all",
4343
description: "Evaluate all the formulae, casks and aliases in the new tap to check validity. " \
44-
"Implied if `HOMEBREW_EVAL_ALL` is set."
44+
"Implied if `$HOMEBREW_EVAL_ALL` is set."
4545
switch "-f", "--force",
4646
description: "Force install core taps even under API mode."
4747

Library/Homebrew/cmd/upgrade.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class UpgradeCmd < AbstractCommand
1919
installed with, plus any appended brew formula options. If <cask> or <formula> are specified,
2020
upgrade only the given <cask> or <formula> kegs (unless they are pinned; see `pin`, `unpin`).
2121
22-
Unless `HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
22+
Unless `$HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK` is set, `brew upgrade` or `brew reinstall` will be run for
2323
outdated dependents and dependents with broken linkage, respectively.
2424
25-
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
25+
Unless `$HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
2626
upgraded formulae or, every 30 days, for all formulae.
2727
EOS
2828
switch "-d", "--debug",

Library/Homebrew/cmd/uses.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def intersection_of_dependents(use_runtime_dependents, used_formulae)
122122
all = args.eval_all?
123123

124124
if !args.installed? && !(all || Homebrew::EnvConfig.eval_all?)
125-
raise UsageError, "`brew uses` needs `--installed` or `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!"
125+
raise UsageError, "`brew uses` needs `--installed` or `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!"
126126
end
127127

128128
if show_formulae_and_casks || args.formula?

Library/Homebrew/dev-cmd/livecheck.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class LivecheckCmd < AbstractCommand
1414
Check for newer versions of formulae and/or casks from upstream.
1515
If no formula or cask argument is passed, the list of formulae and
1616
casks to check is taken from `HOMEBREW_LIVECHECK_WATCHLIST` or
17-
`~/.homebrew/livecheck_watchlist.txt`.
17+
`${HOME}/.homebrew/livecheck_watchlist.txt`.
1818
EOS
1919
switch "--full-name",
2020
description: "Print formulae and casks with fully-qualified names."

0 commit comments

Comments
 (0)