Let’s say I have a simple program like this:
while (true) {
const command = prompt('Enter something');
if (!command) {
Deno.exit(0);
}
}
What I want to do is replicate bash’s behavior where:
- Hitting Ctrl-d exits the process
- Hitting Ctrl-c is effectively just a
continue
so it goes to the next iteration of the loop
But it looks like by default the prompt function returns null in either case. Since the signal handler is async, I can’t see how I’d use one to distinguish whether the input was Ctrl-c vs Ctrl-d. Is there another way to do this?