Skip to content
GitLab
菜单
项目
群组
代码片段
/
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录/注册
切换导航
菜单
打开侧边栏
KMSCAKKSCFKA AKFACAMADCAS
brew
提交
9be410b3
未验证
提交
9be410b3
编辑于
11月 23, 2021
作者:
Mike McQuaid
提交者:
GitHub
11月 23, 2021
浏览文件
Merge pull request #12465 from XuehaiPan/bat-back-to-cat
dev-cmd/cat: auto-install `bat` when running `brew cat ...` with `HOMEBREW_BAT` set
上级
1564d768
c6719e58
变更
2
Hide whitespace changes
Inline
Side-by-side
Library/Homebrew/dev-cmd/cat.rb
浏览文件 @
9be410b3
...
...
@@ -31,8 +31,18 @@ module Homebrew
cd
HOMEBREW_REPOSITORY
pager
=
if
Homebrew
::
EnvConfig
.
bat?
require
"formula"
unless
Formula
[
"bat"
].
any_version_installed?
# The user might want to capture the output of `brew cat ...`
# Redirect stdout to stderr
redirect_stdout
(
$stderr
)
do
ohai
"Installing `bat` for displaying <formula>/<cask> source..."
safe_system
HOMEBREW_BREW_FILE
,
"install"
,
"bat"
end
end
ENV
[
"BAT_CONFIG_PATH"
]
=
Homebrew
::
EnvConfig
.
bat_config_path
"
#{
HOMEBREW_PREFIX
}
/
bin/bat"
Formula
[
"bat"
].
opt_
bin
/
"
bat"
else
"cat"
end
...
...
Library/Homebrew/utils.rb
浏览文件 @
9be410b3
...
...
@@ -437,21 +437,23 @@ module Kernel
$stderr
=
old
end
def
nostdout
def
nostdout
(
&
block
)
if
verbose?
yield
else
begin
out
=
$stdout
.
dup
$stdout
.
reopen
(
File
::
NULL
)
yield
ensure
$stdout
.
reopen
(
out
)
out
.
close
end
redirect_stdout
(
File
::
NULL
,
&
block
)
end
end
def
redirect_stdout
(
file
)
out
=
$stdout
.
dup
$stdout
.
reopen
(
file
)
yield
ensure
$stdout
.
reopen
(
out
)
out
.
close
end
def
paths
@paths
||=
PATH
.
new
(
ENV
[
"HOMEBREW_PATH"
]).
map
do
|
p
|
File
.
expand_path
(
p
).
chomp
(
"/"
)
...
...
编辑
预览
支持
Markdown
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录