Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CTRL-c to stop entry in REPL #4405

Merged
merged 2 commits into from Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/core.c/REPL.pm6
Expand Up @@ -309,6 +309,12 @@ do {
method interactive_prompt() { '> ' }

method repl-loop(:$no-exit, *%adverbs) {
my int $stopped; # did we press CTRL-c just now?
signal(SIGINT).tap: {
exit if $stopped++;
say "Pressed CTRL-c, press CTRL-c again to exit";
print self.interactive_prompt;
}

say $no-exit
?? "Type 'exit' to leave"
Expand All @@ -328,6 +334,7 @@ do {
my $newcode = self.repl-read(~$prompt);
last if $no-exit and $newcode and $newcode eq 'exit';

$stopped = 0;
my $initial_out_position = $*OUT.tell;

# An undef $newcode implies ^D or similar
Expand Down