988: def sh(*cmd, &block)
989: options = (Hash === cmd.last) ? cmd.pop : {}
990: unless block_given?
991: show_command = cmd.join(" ")
992: show_command = show_command[0,42] + "..." unless $trace
993:
994: block = lambda { |ok, status|
995: ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
996: }
997: end
998: if RakeFileUtils.verbose_flag == :default
999: options[:verbose] = true
1000: else
1001: options[:verbose] ||= RakeFileUtils.verbose_flag
1002: end
1003: options[:noop] ||= RakeFileUtils.nowrite_flag
1004: rake_check_options options, :noop, :verbose
1005: rake_output_message cmd.join(" ") if options[:verbose]
1006: unless options[:noop]
1007: res = rake_system(*cmd)
1008: status = $?
1009: status = PseudoStatus.new(1) if !res && status.nil?
1010: block.call(res, status)
1011: end
1012: end