From 7062315d6b2c6950d3f57bc4f897a304618debf0 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Sat, 17 Jun 2017 13:45:12 -0700 Subject: [PATCH] fix shell mode interpolation while allowing special chars in commands fixes #22176, see also #20494 and #20482 --- base/REPL.jl | 4 +++- base/REPLCompletions.jl | 2 +- base/process.jl | 2 +- base/shell.jl | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/base/REPL.jl b/base/REPL.jl index 8054e048600cbe..ec8d8f3b193b9d 100644 --- a/base/REPL.jl +++ b/base/REPL.jl @@ -750,7 +750,9 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep # and pass into Base.repl_cmd for processing (handles `ls` and `cd` # special) on_done = respond(repl, julia_prompt) do line - Expr(:call, :(Base.repl_cmd), Cmd(Base.shell_split(line)), outstream(repl)) + Expr(:call, :(Base.repl_cmd), + :(Base.cmd_gen($(Base.shell_parse(line)[1]))), + outstream(repl)) end) diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index d58aebe5f98329..7f0f03cf940712 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -586,7 +586,7 @@ function shell_completions(string, pos) use_envpath = !ignore_last_word && length(args.args) < 2 return complete_path(prefix, pos, use_envpath=use_envpath) - elseif isexpr(arg, :escape) && (isexpr(arg.args[1], :incomplete) || isexpr(arg.args[1], :error)) + elseif isexpr(arg, :incomplete) || isexpr(arg, :error) r = first(last_parse):prevind(last_parse, last(last_parse)) partial = scs[r] ret, range = completions(partial, endof(partial)) diff --git a/base/process.jl b/base/process.jl index b3ac98e28387b8..d7dff2fecb5c79 100644 --- a/base/process.jl +++ b/base/process.jl @@ -793,7 +793,7 @@ function cmd_gen(parsed) end macro cmd(str) - return :(cmd_gen($(shell_parse(str, special=shell_special)[1]))) + return :(cmd_gen($(esc(shell_parse(str, special=shell_special)[1])))) end wait(x::Process) = if !process_exited(x); stream_wait(x, x.exitnotify); end diff --git a/base/shell.jl b/base/shell.jl index a6a8d2fddb48ae..841865790b9c9e 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -75,7 +75,7 @@ function shell_parse(str::AbstractString, interpolate::Bool=true; stpos = j ex, j = parse(s,j,greedy=false) last_parse = stpos:j - update_arg(esc(ex)); i = j + update_arg(ex); i = j else if !in_double_quotes && c == '\'' in_single_quotes = !in_single_quotes