@@ -31,8 +31,15 @@ stackframe_lineinfo_color() = repl_color("JULIA_STACKFRAME_LINEINFO_COLOR", :bol
3131stackframe_function_color () = repl_color (" JULIA_STACKFRAME_FUNCTION_COLOR" , :bold )
3232
3333function repl_cmd (cmd, out)
34- shell = shell_split (get (ENV , " JULIA_SHELL" , get (ENV , " SHELL" , " /bin/sh" )))
34+ shell = get (ENV , " JULIA_SHELL" , nothing )
35+ if shell === nothing || isempty (shell)
36+ shell = Sys. iswindows () ? " cmd" : get (ENV , " SHELL" , " /bin/sh" )
37+ end
38+ shell = shell_split (shell)
3539 shell_name = Base. basename (shell[1 ])
40+ if Sys. iswindows ()
41+ shell_name = lowercase (splitext (shell_name)[1 ]) # canonicalize for comparisons below
42+ end
3643
3744 # Immediately expand all arguments, so that typing e.g. ~/bin/foo works.
3845 cmd. exec .= expanduser .(cmd. exec)
@@ -66,15 +73,28 @@ function repl_cmd(cmd, out)
6673 ENV [" OLDPWD" ] = new_oldpwd
6774 println (out, pwd ())
6875 else
69- @static if ! Sys. iswindows ()
76+ local command:: Cmd
77+ if Sys. iswindows ()
78+ if shell_name == " "
79+ command = cmd
80+ elseif shell_name == " cmd"
81+ command = Cmd (` $shell /c $(shell_escape_CMDly (shell_escape_winsomely (cmd))) ` , windows_verbatim= true )
82+ elseif shell_name in (" powershell" , " pwsh" )
83+ command = Cmd (` $shell -Command $(shell_escape_PWSHly (shell_escape_winsomely (cmd))) ` , windows_verbatim= true )
84+ elseif shell_name == " busybox"
85+ command = ` $shell sh -c $(shell_escape_posixly (cmd)) `
86+ else
87+ command = ` $shell $cmd `
88+ end
89+ else
7090 if shell_name == " fish"
7191 shell_escape_cmd = " begin; $(shell_escape_posixly (cmd)) ; and true; end"
7292 else
7393 shell_escape_cmd = " ($(shell_escape_posixly (cmd)) ) && true"
7494 end
75- cmd = ` $shell -c $shell_escape_cmd `
95+ command = ` $shell -c $shell_escape_cmd `
7696 end
77- run (ignorestatus (cmd ))
97+ run (ignorestatus (command ))
7898 end
7999 nothing
80100end
0 commit comments