475: def sh(*cmd, &block)
476: if Hash === cmd.last then
477: options = cmd.pop
478: else
479: options = {}
480: end
481: unless block_given?
482: show_command = cmd.join(" ")
483: show_command = show_command[0,42] + "..." if show_command.length > 45
484: block = lambda { |ok, status|
485: ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
486: }
487: end
488: fu_check_options options, :noop, :verbose
489: fu_output_message cmd.join(" ") if options[:verbose]
490: unless options[:noop]
491: res = system(*cmd)
492: block.call(res, $?)
493: end
494: end