File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ module FileUtils
2929 #
3030 def sh ( *cmd , &block )
3131 options = ( Hash === cmd . last ) ? cmd . pop : { }
32- block = create_shell_command ( cmd ) unless block_given?
32+ shell_runner = block_given? ? block : create_shell_runner ( cmd )
3333 set_verbose_option ( options )
3434 options [ :noop ] ||= RakeFileUtils . nowrite_flag
3535 rake_check_options options , :noop , :verbose
@@ -38,17 +38,18 @@ def sh(*cmd, &block)
3838 res = rake_system ( *cmd )
3939 status = $?
4040 status = PseudoStatus . new ( 1 ) if !res && status . nil?
41- block . call ( res , status )
41+ shell_runner . call ( res , status )
4242 end
4343 end
4444
45- def create_shell_command ( cmd )
45+ def create_shell_runner ( cmd )
4646 show_command = cmd . join ( " " )
4747 show_command = show_command [ 0 , 42 ] + "..." unless $trace
4848 block = lambda { |ok , status |
4949 ok or fail "Command failed with status (#{ status . exitstatus } ): [#{ show_command } ]"
5050 }
5151 end
52+ private :create_shell_runner
5253
5354 def set_verbose_option ( options )
5455 if options [ :verbose ] . nil?
You can’t perform that action at this time.
0 commit comments