Skip to content

Commit 5455582

Browse files
authored
Refine exit commands (#7)
* Change q[uit]! command's behavior - `quit`, `q` - quit with confirmation - `quit!`, `q!` - quit immediately
1 parent 8d3576e commit 5455582

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,14 @@ The `<...>` notation means the argument.
321321
* Finish this frame. Resume the program until the current frame is finished.
322322
* `c[ontinue]`
323323
* Resume the program.
324-
* `q[uit]` or exit or `Ctrl-D`
324+
* `q[uit]` or `Ctrl-D`
325325
* Finish debugger (with the debuggee process on non-remote debugging).
326-
* `kill` or `q[uit]!`
327-
* Stop the debuggee process.
326+
* `q[uit]!`
327+
* Same as q[uit] but without the confirmation prompt.
328+
* `kill`
329+
* Stop the debuggee process with `Kernal#exit!`.
330+
* `kill!`
331+
* Same as kill but without the confirmation prompt.
328332

329333
### Breakpoint
330334

lib/debug/session.rb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,36 @@ def wait_command
231231
when 'c', 'continue'
232232
@tc << :continue
233233

234-
# * `q[uit]` or exit or `Ctrl-D`
234+
# * `q[uit]` or `Ctrl-D`
235235
# * Finish debugger (with the debuggee process on non-remote debugging).
236-
when 'q', 'quit', 'exit'
236+
when 'q', 'quit'
237237
if ask 'Really quit?'
238238
@ui.quit arg.to_i
239239
@tc << :continue
240240
else
241241
return :retry
242242
end
243243

244-
# * `kill` or `q[uit]!`
245-
# * Stop the debuggee process.
246-
when 'kill', 'quit!', 'q!'
244+
# * `q[uit]!`
245+
# * Same as q[uit] but without the confirmation prompt.
246+
when 'q!', 'quit!'
247+
@ui.quit arg.to_i
248+
@tc << :continue
249+
250+
# * `kill`
251+
# * Stop the debuggee process with `Kernal#exit!`.
252+
when 'kill'
247253
if ask 'Really kill?'
248254
exit! (arg || 1).to_i
249255
else
250256
return :retry
251257
end
252258

259+
# * `kill!`
260+
# * Same as kill but without the confirmation prompt.
261+
when 'kill!'
262+
exit! (arg || 1).to_i
263+
253264
### Breakpoint
254265

255266
# * `b[reak]`
@@ -417,7 +428,7 @@ def wait_command
417428
# * Show the result of `<expr>` at every suspended timing.
418429
when 'display'
419430
if arg && !arg.empty?
420-
@displays << arg
431+
@displays << arg
421432
@tc << [:eval, :try_display, @displays]
422433
else
423434
@tc << [:eval, :display, @displays]
@@ -808,7 +819,7 @@ def stop_all_threads
808819
end
809820
end
810821

811-
## event
822+
## event
812823

813824
def on_load iseq, src
814825
@sr.add iseq, src

0 commit comments

Comments
 (0)