@@ -29,16 +29,9 @@ module FileUtils
29
29
#
30
30
def sh ( *cmd , &block )
31
31
options = ( Hash === cmd . last ) ? cmd . pop : { }
32
- unless block_given?
33
- show_command = cmd . join ( " " )
34
- show_command = show_command [ 0 , 42 ] + "..." unless $trace
35
- # TODO code application logic heref show_command.length > 45
36
- block = lambda { |ok , status |
37
- ok or fail "Command failed with status (#{ status . exitstatus } ): [#{ show_command } ]"
38
- }
39
- end
32
+ block = create_shell_command ( cmd ) unless block_given?
40
33
set_verbose_option ( options )
41
- options [ :noop ] ||= RakeFileUtils . nowrite_flag
34
+ options [ :noop ] ||= RakeFileUtils . nowrite_flag
42
35
rake_check_options options , :noop , :verbose
43
36
rake_output_message cmd . join ( " " ) if options [ :verbose ]
44
37
unless options [ :noop ]
@@ -49,11 +42,17 @@ def sh(*cmd, &block)
49
42
end
50
43
end
51
44
45
+ def create_shell_command ( cmd )
46
+ show_command = cmd . join ( " " )
47
+ show_command = show_command [ 0 , 42 ] + "..." unless $trace
48
+ block = lambda { |ok , status |
49
+ ok or fail "Command failed with status (#{ status . exitstatus } ): [#{ show_command } ]"
50
+ }
51
+ end
52
+
52
53
def set_verbose_option ( options )
53
- if RakeFileUtils . verbose_flag . nil? && options [ :verbose ] . nil?
54
- options [ :verbose ] = true
55
- elsif options [ :verbose ] . nil?
56
- options [ :verbose ] ||= RakeFileUtils . verbose_flag
54
+ if options [ :verbose ] . nil?
55
+ options [ :verbose ] = RakeFileUtils . verbose_flag . nil? || RakeFileUtils . verbose_flag
57
56
end
58
57
end
59
58
private :set_verbose_option
0 commit comments