[ruby/irb] Centralize rstrip calls

(https://github.com/ruby/irb/pull/918)

https://github.com/ruby/irb/commit/97898b6251
This commit is contained in:
Stan Lo 2024-04-11 01:33:40 +08:00 committed by git
parent d60b2caa95
commit d75dc39880
10 changed files with 12 additions and 9 deletions

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Backtrace < DebugCommand class Backtrace < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(pre_cmds: "backtrace #{arg}".rstrip) execute_debug_command(pre_cmds: "backtrace #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Break < DebugCommand class Break < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(pre_cmds: "break #{arg}".rstrip) execute_debug_command(pre_cmds: "break #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Catch < DebugCommand class Catch < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(pre_cmds: "catch #{arg}".rstrip) execute_debug_command(pre_cmds: "catch #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Continue < DebugCommand class Continue < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(do_cmds: "continue #{arg}".rstrip) execute_debug_command(do_cmds: "continue #{arg}")
end end
end end
end end

View File

@ -18,6 +18,9 @@ module IRB
end end
def execute_debug_command(pre_cmds: nil, do_cmds: nil) def execute_debug_command(pre_cmds: nil, do_cmds: nil)
pre_cmds = pre_cmds&.rstrip
do_cmds = do_cmds&.rstrip
if irb_context.with_debugger if irb_context.with_debugger
# If IRB is already running with a debug session, throw the command and IRB.debug_readline will pass it to the debugger. # If IRB is already running with a debug session, throw the command and IRB.debug_readline will pass it to the debugger.
if cmd = pre_cmds || do_cmds if cmd = pre_cmds || do_cmds

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Delete < DebugCommand class Delete < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(pre_cmds: "delete #{arg}".rstrip) execute_debug_command(pre_cmds: "delete #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Finish < DebugCommand class Finish < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(do_cmds: "finish #{arg}".rstrip) execute_debug_command(do_cmds: "finish #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Info < DebugCommand class Info < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(pre_cmds: "info #{arg}".rstrip) execute_debug_command(pre_cmds: "info #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Next < DebugCommand class Next < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(do_cmds: "next #{arg}".rstrip) execute_debug_command(do_cmds: "next #{arg}")
end end
end end
end end

View File

@ -8,7 +8,7 @@ module IRB
module Command module Command
class Step < DebugCommand class Step < DebugCommand
def execute(arg) def execute(arg)
execute_debug_command(do_cmds: "step #{arg}".rstrip) execute_debug_command(do_cmds: "step #{arg}")
end end
end end
end end