Merge pull request #8482 from maxim-belkin/non-interactive-sh
dev-cmd/sh.rb: non-interactive mode
This commit is contained in:
commit
fcacd46a43
@ -10,18 +10,19 @@ module Homebrew
|
|||||||
def sh_args
|
def sh_args
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
`sh` [<options>]
|
`sh` [<options>] [<file>]
|
||||||
|
|
||||||
Start a Homebrew build environment shell. Uses our years-battle-hardened
|
Homebrew build environment that uses years-battle-hardened
|
||||||
Homebrew build logic to help your `./configure && make && make install`
|
build logic to help your `./configure && make && make install`
|
||||||
or even your `gem install` succeed. Especially handy if you run Homebrew
|
and even your `gem install` succeed. Especially handy if you run Homebrew
|
||||||
in an Xcode-only configuration since it adds tools like `make` to your `PATH`
|
in an Xcode-only configuration since it adds tools like `make` to your `PATH`
|
||||||
which build systems would not find otherwise.
|
which build systems would not find otherwise.
|
||||||
EOS
|
EOS
|
||||||
flag "--env=",
|
flag "--env=",
|
||||||
description: "Use the standard `PATH` instead of superenv's when `std` is passed."
|
description: "Use the standard `PATH` instead of superenv's when `std` is passed."
|
||||||
|
flag "-c=", "--cmd=",
|
||||||
max_named 0
|
description: "Execute commands in a non-interactive shell."
|
||||||
|
max_named 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,12 +40,19 @@ module Homebrew
|
|||||||
# superenv stopped adding brew's bin but generally users will want it
|
# superenv stopped adding brew's bin but generally users will want it
|
||||||
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
|
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ENV["VERBOSE"] = "1" if args.verbose?
|
||||||
|
|
||||||
|
if args.cmd.present?
|
||||||
|
safe_system(ENV["SHELL"], "-c", args.cmd)
|
||||||
|
elsif args.named.present?
|
||||||
|
safe_system(ENV["SHELL"], args.named.first)
|
||||||
|
else
|
||||||
subshell = if ENV["SHELL"].include?("zsh")
|
subshell = if ENV["SHELL"].include?("zsh")
|
||||||
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d"
|
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d"
|
||||||
else
|
else
|
||||||
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}"
|
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}"
|
||||||
end
|
end
|
||||||
ENV["VERBOSE"] = "1"
|
|
||||||
puts <<~EOS
|
puts <<~EOS
|
||||||
Your shell has been configured to use Homebrew's build environment;
|
Your shell has been configured to use Homebrew's build environment;
|
||||||
this should help you build stuff. Notably though, the system versions of
|
this should help you build stuff. Notably though, the system versions of
|
||||||
@ -57,3 +65,4 @@ module Homebrew
|
|||||||
safe_system subshell
|
safe_system subshell
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1106,16 +1106,18 @@ Run a Ruby instance with Homebrew's libraries loaded, e.g.
|
|||||||
* `-e`:
|
* `-e`:
|
||||||
Execute the given text string as a script.
|
Execute the given text string as a script.
|
||||||
|
|
||||||
### `sh` [*`options`*]
|
### `sh` [*`options`*] [*`file`*]
|
||||||
|
|
||||||
Start a Homebrew build environment shell. Uses our years-battle-hardened
|
Homebrew build environment that uses years-battle-hardened
|
||||||
Homebrew build logic to help your `./configure && make && make install`
|
build logic to help your `./configure && make && make install`
|
||||||
or even your `gem install` succeed. Especially handy if you run Homebrew
|
and even your `gem install` succeed. Especially handy if you run Homebrew
|
||||||
in an Xcode-only configuration since it adds tools like `make` to your `PATH`
|
in an Xcode-only configuration since it adds tools like `make` to your `PATH`
|
||||||
which build systems would not find otherwise.
|
which build systems would not find otherwise.
|
||||||
|
|
||||||
* `--env`:
|
* `--env`:
|
||||||
Use the standard `PATH` instead of superenv's when `std` is passed.
|
Use the standard `PATH` instead of superenv's when `std` is passed.
|
||||||
|
* `-c`, `--cmd`:
|
||||||
|
Execute commands in a non-interactive shell.
|
||||||
|
|
||||||
### `sponsors`
|
### `sponsors`
|
||||||
|
|
||||||
|
|||||||
@ -1522,13 +1522,17 @@ Load a library using \fBrequire\fR\.
|
|||||||
\fB\-e\fR
|
\fB\-e\fR
|
||||||
Execute the given text string as a script\.
|
Execute the given text string as a script\.
|
||||||
.
|
.
|
||||||
.SS "\fBsh\fR [\fIoptions\fR]"
|
.SS "\fBsh\fR [\fIoptions\fR] [\fIfile\fR]"
|
||||||
Start a Homebrew build environment shell\. Uses our years\-battle\-hardened Homebrew build logic to help your \fB\./configure && make && make install\fR or even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which build systems would not find otherwise\.
|
Homebrew build environment that uses years\-battle\-hardened build logic to help your \fB\./configure && make && make install\fR and even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which build systems would not find otherwise\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-env\fR
|
\fB\-\-env\fR
|
||||||
Use the standard \fBPATH\fR instead of superenv\'s when \fBstd\fR is passed\.
|
Use the standard \fBPATH\fR instead of superenv\'s when \fBstd\fR is passed\.
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-c\fR, \fB\-\-cmd\fR
|
||||||
|
Execute commands in a non\-interactive shell\.
|
||||||
|
.
|
||||||
.SS "\fBsponsors\fR"
|
.SS "\fBsponsors\fR"
|
||||||
Print a Markdown summary of Homebrew\'s GitHub Sponsors, suitable for pasting into a README\.
|
Print a Markdown summary of Homebrew\'s GitHub Sponsors, suitable for pasting into a README\.
|
||||||
.
|
.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user