Run the system command cmd. If multiple arguments are given the command is not run with the shell (same semantics as Kernel::exec and Kernel::system).
Example:
sh %{ls -ltr} sh 'ls', 'file with spaces' # check exit status after command runs sh %{grep pattern file} do |ok, res| if ! ok puts "pattern not found (status = #{res.exitstatus})" end end
Source Code
# File rake.rb, line 892 def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} unless block_given? show_command = cmd.join(" ") show_command = show_command[0,42] + "..." # TODO code application logic heref show_command.length > 45 block = lambda { |ok, status| ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" } end rake_check_options options, :noop, :verbose rake_output_message cmd.join(" ") if options[:verbose] unless options[:noop] res = system(*cmd) block.call(res, $?) end end
<code/>and<pre/>for code samples.