File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,30 @@ options = OpenStruct.new(
1313 'gems_to_include' => [ ]
1414)
1515
16+ module DebugPrinter
17+
18+ class << self
19+ attr_accessor :cli_debug
20+
21+ def print_debug ( msg )
22+ if DebugPrinter . cli_debug
23+ delimiter = '=' * 10
24+ upper_border = "\n #{ delimiter } \n "
25+ lower_border = "#{ delimiter } \n \n "
26+
27+ if msg . length > 0 and msg [ msg . length - 1 ] != "\n "
28+ lower_border = "\n " + lower_border
29+ end
30+
31+ $stdout. puts upper_border + msg + lower_border
32+ end
33+ end
34+ end
35+
36+ end
37+
38+ DebugPrinter . cli_debug = ARGV . include? '--debug'
39+
1640opts = OptionParser . new do |opts |
1741 # TODO need some banner
1842 opts . banner = <<EOB
@@ -110,6 +134,9 @@ class NativeDebugger
110134 break if line =~ /\$ \d +\s =\s "#{ @delimiter } "/
111135 content += line
112136 end
137+
138+ DebugPrinter . print_debug ( content )
139+
113140 content
114141 end
115142
@@ -317,7 +344,13 @@ class ProcessThread
317344end
318345
319346def command_exists ( command )
347+ checking_command = "checking command #{ command } for existence\n "
320348 `command -v #{ command } >/dev/null 2>&1 || { exit 1; }`
349+ if $?. exitstatus != 0
350+ DebugPrinter . print_debug ( "#{ checking_command } command does not exist." )
351+ else
352+ DebugPrinter . print_debug ( "#{ checking_command } command does exist." )
353+ end
321354 $?. exitstatus == 0
322355end
323356
@@ -348,6 +381,7 @@ debugger.attach_to_process
348381debugger . set_flags
349382
350383if options . uid
384+ DebugPrinter . print_debug ( "changing current uid from #{ Process . uid } to #{ options . uid } " )
351385 Process ::Sys . setuid ( options . uid . to_i )
352386end
353387
You can’t perform that action at this time.
0 commit comments