Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,7 @@ stackframe_function_color() = repl_color("JULIA_STACKFRAME_FUNCTION_COLOR", :bol

function repl_cmd(cmd, out)
shell = shell_split(get(ENV,"JULIA_SHELL",get(ENV,"SHELL","/bin/sh")))
# Note that we can't support the fish shell due to its lack of subshells
# See this for details: https://github.com/JuliaLang/julia/issues/4918
if Base.basename(shell[1]) == "fish"
warn_once("cannot use the fish shell, defaulting to /bin/sh\
set the JULIA_SHELL environment variable to silence this warning")
shell = "/bin/sh"
end
shell_name = Base.basename(shell[1])

if isempty(cmd.exec)
throw(ArgumentError("no cmd to execute"))
Expand All @@ -120,11 +114,19 @@ function repl_cmd(cmd, out)
ENV["OLDPWD"] = new_oldpwd
println(out, pwd())
else
run(ignorestatus(@static is_windows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "($(shell_escape(cmd))) && true"` : `$shell -c "($(shell_escape(cmd))) && true"`)))
run(ignorestatus(@static is_windows() ? cmd : (isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)))
end
nothing
end

function shell_wrap_true(shell_name, cmd)
if shell_name == "fish"
"begin; $(shell_escape(cmd)); and true; end"
else
"($(shell_escape(cmd))) && true"
end
end

function display_error(io::IO, er, bt)
if !isempty(bt)
st = stacktrace(bt)
Expand Down