Skip to content

Commit

Permalink
fix shell mode interpolation while allowing special chars in commands
Browse files Browse the repository at this point in the history
fixes #22176, see also #20494 and #20482
  • Loading branch information
StefanKarpinski committed Jun 17, 2017
1 parent ad290e9 commit 7062315
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion base/REPL.jl
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion base/REPLCompletions.jl
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion base/process.jl
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/shell.jl
Expand Up @@ -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
Expand Down

0 comments on commit 7062315

Please sign in to comment.