Skip to content

feat: add ctrl+c support to quit#10

Closed
maxelkins wants to merge 2 commits intogrega:mainfrom
maxelkins:quit-with-ctrl-c
Closed

feat: add ctrl+c support to quit#10
maxelkins wants to merge 2 commits intogrega:mainfrom
maxelkins:quit-with-ctrl-c

Conversation

@maxelkins
Copy link
Contributor

Summary

closes #8

Bit vibey but all seems to make sense. Wasn't sure on removal of INT (due to my lack of understanding) but seems logical when explained with AI...

INT was removed because it either did nothing useful (raw mode) or fired at the wrong time (during command execution).

Scenario With INT trap Without INT trap
Ctrl+C in raw mode (read_key) Does nothing (no signal sent) Captured as \x03 → ctrl-c key handler
Ctrl+C during eval "$cmd" cleanup fires mid-command (bad) Child killed, script continues normally
Ctrl+C elsewhere cleanup fires EXIT trap handles it anyway

@grega
Copy link
Owner

grega commented Mar 24, 2026

@maxelkins sorry I saw this after committing 87174e2 !

Implementations are broadly the same, I did pop a test in too (keen to avoid regressions).

As for INT the intent here is that when running hdi, if the "Execute" functionality is used (eg. to run an npm install command from a README)

  • And the execution is long running
  • And Ctrl-C is hit during execution

INT should ensure that both the command being executed and hdi are properly, and cleanly quit, rather than leaving the terminal / cursor in an intermediate state.

But, I think just using trap cleanup EXIT is sufficient. Will go and poke around some tests...

@grega grega closed this Mar 24, 2026
@grega grega mentioned this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quit with ctrl+c

2 participants