From 2aaf9ea671c634fee21714da1f10e59a23e87d65 Mon Sep 17 00:00:00 2001 From: Carsten Bauer Date: Fri, 4 Dec 2020 00:51:43 +0100 Subject: [PATCH] Sticky shell REPL mode (#38646) * make shell REPL mode sticky * fix tests * fix precompile statement generation script --- contrib/generate_precompile.jl | 1 + stdlib/REPL/src/REPL.jl | 3 ++- stdlib/REPL/test/repl.jl | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index 015d510880170..2f25a2bb4605a 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -41,6 +41,7 @@ display([1]) display([1 2; 3 4]) @time 1+1 ; pwd +$CTRL_C ? reinterpret using Ra\t$CTRL_C \\alpha\t$CTRL_C diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 341322ef1aab1..6b6c37425e70b 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -920,7 +920,8 @@ function setup_interface( Expr(:call, :(Base.repl_cmd), :(Base.cmd_gen($(Base.shell_parse(line::String)[1]))), outstream(repl)) - end) + end, + sticky = true) ################################# Stage II ############################# diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 1025b509d769b..7666dd04d9219 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -139,6 +139,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri readuntil(stdout_read, "\n") readuntil(stdout_read, "\n") @test samefile(".", tmpdir) + write(stdin_write, "\b") # Test using `cd` to move to the home directory write(stdin_write, ";") @@ -148,6 +149,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri readuntil(stdout_read, "\n") readuntil(stdout_read, "\n") @test samefile(".", homedir_pwd) + write(stdin_write, "\b") # Test using `-` to jump backward to tmpdir write(stdin_write, ";") @@ -157,6 +159,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri readuntil(stdout_read, "\n") readuntil(stdout_read, "\n") @test samefile(".", tmpdir) + write(stdin_write, "\b") # Test using `~` (Base.expanduser) in `cd` commands if !Sys.iswindows() @@ -167,6 +170,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri readuntil(stdout_read, "\n") readuntil(stdout_read, "\n") @test samefile(".", homedir_pwd) + write(stdin_write, "\b") end finally cd(origpwd) @@ -196,6 +200,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri s = readuntil(stdout_read, "\n\n") @test startswith(s, "\e[0mERROR: unterminated single quote\nStacktrace:\n [1] ") || startswith(s, "\e[0m\e[1m\e[91mERROR: \e[39m\e[22m\e[91munterminated single quote\e[39m\nStacktrace:\n [1] ") + write(stdin_write, "\b") end # issue #27293 @@ -219,6 +224,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri close(proc_stdout) # check for the correct, expanded response @test occursin(expanduser("~"), fetch(get_stdout)) + write(stdin_write, "\b") end end @@ -270,6 +276,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri end close(proc_stdout) @test fetch(get_stdout) == "HI\n" + write(stdin_write, "\b") end # Issue #7001