Skip to content
Snippets Groups Projects
Commit 28c43f1a authored by Maxim Belkin's avatar Maxim Belkin
Browse files

dev-cmd/sh.rb: non-interactive mode

parent ff8d30df
No related branches found
No related tags found
No related merge requests found
...@@ -10,18 +10,19 @@ module Homebrew ...@@ -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>] [<commands>]
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,21 +40,29 @@ module Homebrew ...@@ -39,21 +40,29 @@ 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
subshell = if ENV["SHELL"].include?("zsh")
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d" 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[0])
else else
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}" subshell = if ENV["SHELL"].include?("zsh")
"PS1='brew %B%F{green}%~%f%b$ ' #{ENV["SHELL"]} -d"
else
"PS1=\"brew \\[\\033[1;32m\\]\\w\\[\\033[0m\\]$ \" #{ENV["SHELL"]}"
end
puts <<~EOS
Your shell has been configured to use Homebrew's build environment;
this should help you build stuff. Notably though, the system versions of
gem and pip will ignore our configuration and insist on using the
environment they were built under (mostly). Sadly, scons will also
ignore our configuration.
When done, type `exit`.
EOS
$stdout.flush
safe_system subshell
end end
ENV["VERBOSE"] = "1"
puts <<~EOS
Your shell has been configured to use Homebrew's build environment;
this should help you build stuff. Notably though, the system versions of
gem and pip will ignore our configuration and insist on using the
environment they were built under (mostly). Sadly, scons will also
ignore our configuration.
When done, type `exit`.
EOS
$stdout.flush
safe_system subshell
end end
end end
...@@ -1106,16 +1106,18 @@ Run a Ruby instance with Homebrew's libraries loaded, e.g. ...@@ -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`*] [*`commands`*]
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\. ...@@ -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] [\fIcommands\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\.
. .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment