Skip to content

Commit

Permalink
Sticky shell REPL mode (JuliaLang#38646)
Browse files Browse the repository at this point in the history
* make shell REPL mode sticky

* fix tests

* fix precompile statement generation script
  • Loading branch information
carstenbauer committed Dec 3, 2020
1 parent 9631a9f commit 2aaf9ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 #############################
Expand Down
7 changes: 7 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, ";")
Expand All @@ -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, ";")
Expand All @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2aaf9ea

Please sign in to comment.