Merge pull request #5942 from MikeMcQuaid/system-not-exec
*cmd/*: use *system instead of exec for easier testing.
This commit is contained in:
commit
9dba22f950
@ -23,6 +23,6 @@ module Homebrew
|
||||
raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1
|
||||
|
||||
cd HOMEBREW_REPOSITORY
|
||||
exec "cat", formulae.first.path, *ARGV.options_only
|
||||
safe_system "cat", formulae.first.path, *ARGV.options_only
|
||||
end
|
||||
end
|
||||
|
@ -46,8 +46,7 @@ module Homebrew
|
||||
def list
|
||||
list_args.parse
|
||||
|
||||
# Use of exec means we don't explicitly exit
|
||||
list_unbrewed if args.unbrewed?
|
||||
return list_unbrewed if args.unbrewed?
|
||||
|
||||
# Unbrewed uses the PREFIX, which will exist
|
||||
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
||||
@ -67,10 +66,10 @@ module Homebrew
|
||||
puts Formatter.columns(full_names)
|
||||
else
|
||||
ENV["CLICOLOR"] = nil
|
||||
exec "ls", *ARGV.options_only << HOMEBREW_CELLAR
|
||||
safe_system "ls", *ARGV.options_only << HOMEBREW_CELLAR
|
||||
end
|
||||
elsif args.verbose? || !$stdout.tty?
|
||||
exec "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print]
|
||||
safe_system "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print]
|
||||
else
|
||||
ARGV.kegs.each { |keg| PrettyListing.new keg }
|
||||
end
|
||||
@ -116,7 +115,7 @@ module Homebrew
|
||||
arguments.concat %w[)]
|
||||
|
||||
cd HOMEBREW_PREFIX
|
||||
exec "find", *arguments
|
||||
safe_system "find", *arguments
|
||||
end
|
||||
|
||||
def filtered_list
|
||||
|
@ -56,6 +56,6 @@ module Homebrew
|
||||
end
|
||||
args = ARGV.options_only
|
||||
args += ["--follow", "--", path] unless path.nil?
|
||||
exec "git", "log", *args
|
||||
system "git", "log", *args
|
||||
end
|
||||
end
|
||||
|
@ -51,6 +51,6 @@ module Homebrew
|
||||
When done, type `exit'.
|
||||
EOS
|
||||
$stdout.flush
|
||||
exec ENV["SHELL"]
|
||||
safe_system ENV["SHELL"]
|
||||
end
|
||||
end
|
||||
|
@ -19,6 +19,6 @@ module Homebrew
|
||||
Homebrew.install_gem_setup_path! "ruby-prof"
|
||||
FileUtils.mkdir_p "prof"
|
||||
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
||||
exec "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *ARGV
|
||||
safe_system "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *ARGV
|
||||
end
|
||||
end
|
||||
|
@ -21,6 +21,9 @@ module Homebrew
|
||||
def ruby
|
||||
ruby_args.parse
|
||||
|
||||
exec ENV["HOMEBREW_RUBY_PATH"], "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), "-rglobal", "-rdev-cmd/irb", *ARGV
|
||||
safe_system ENV["HOMEBREW_RUBY_PATH"],
|
||||
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
|
||||
"-rglobal", "-rdev-cmd/irb",
|
||||
*ARGV
|
||||
end
|
||||
end
|
||||
|
@ -321,7 +321,7 @@ end
|
||||
|
||||
def exec_editor(*args)
|
||||
puts "Editing #{args.join "\n"}"
|
||||
with_homebrew_path { safe_exec(which_editor, *args) }
|
||||
with_homebrew_path { safe_system(which_editor, *args) }
|
||||
end
|
||||
|
||||
def exec_browser(*args)
|
||||
@ -331,13 +331,7 @@ def exec_browser(*args)
|
||||
|
||||
ENV["DISPLAY"] = ENV["HOMEBREW_DISPLAY"]
|
||||
|
||||
safe_exec(browser, *args)
|
||||
end
|
||||
|
||||
def safe_exec(cmd, *args)
|
||||
# This buys us proper argument quoting and evaluation
|
||||
# of environment variables in the cmd parameter.
|
||||
exec "/bin/sh", "-c", "#{cmd} \"$@\"", "--", *args
|
||||
safe_system(browser, *args)
|
||||
end
|
||||
|
||||
# GZips the given paths, and returns the gzipped paths
|
||||
|
Loading…
x
Reference in New Issue
Block a user