From 6399951f7f7c331e0964f1a82d6c049a19046894 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Wed, 17 Mar 2021 16:07:01 -0400 Subject: [PATCH 1/2] REPL-only: Print a hint if the user types `exit` in the REPL --- stdlib/REPL/src/REPL.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 68f157322facc..8ee1c134320ca 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -370,6 +370,7 @@ function run_frontend(repl::BasicREPL, backend::REPLBackendRef) if !isempty(line) response = eval_with_backend(ast, backend) print_response(repl, response, !ends_with_semicolon(line), false) + print_exit_hint(repl, line) end write(repl.terminal, '\n') ((!interrupted && isempty(line)) || hit_eof) && break @@ -796,6 +797,7 @@ function respond(f, repl, main; pass_empty::Bool = false, suppress_on_semicolon: end hide_output = suppress_on_semicolon && ends_with_semicolon(line) print_response(repl, response, !hide_output, hascolor(repl)) + print_exit_hint(repl, line) end prepare_next(repl) reset_state(s) @@ -1224,6 +1226,7 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef) end response = eval_with_backend(ast, backend) print_response(repl, response, !ends_with_semicolon(line), have_color) + print_exit_hint(repl, line) end end # Terminate Backend @@ -1232,4 +1235,20 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef) nothing end +function start_repl_server(port::Int) + return listen(port) do server, status + client = accept(server) + run_repl(client) + nothing + end +end + +print_exit_hint(repl::AbstractREPL, line) = print_exit_hint(outstream(repl), line) +function print_exit_hint(io::IO, line) + if lowercase(strip(line)) == "exit" + println(io, "\nTo exit Julia, use Ctrl-D, or type exit() and press enter.") + end + return nothing +end + end # module From 211ce915374326dfcd4e0ef01d3405414a2e9c06 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Thu, 15 Apr 2021 20:58:16 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Jameson Nash --- stdlib/REPL/src/REPL.jl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 8ee1c134320ca..d77ca45f19eb2 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1235,14 +1235,6 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef) nothing end -function start_repl_server(port::Int) - return listen(port) do server, status - client = accept(server) - run_repl(client) - nothing - end -end - print_exit_hint(repl::AbstractREPL, line) = print_exit_hint(outstream(repl), line) function print_exit_hint(io::IO, line) if lowercase(strip(line)) == "exit"