How do you use the shell from the interpreter? Is this correct?

windows

#1

I’m using Julia 0.5.0 on Windows 7, and having some issues with doing shell commands in REPL.

I use the desktop shortcut to launch Julia, then type a semicolon and the prompt changes to shell>. Then I type dir, which on Windows, should list the contents of the directory. Instead, I get the following error.

shell> DIR
ERROR: could not spawn `DIR`: no such file or directory (ENOENT)
 in _jl_spawn(::String, ::Array{String,1}, ::Ptr{Void}, ::Base.Process, ::RawFD, ::RawFD, ::RawFD) at .\process.jl:321
 in #414 at .\process.jl:478 [inlined]
 in setup_stdio(::Base.##414#415{Cmd,Ptr{Void},Base.Process}, ::Tuple{RawFD,RawFD,RawFD}) at .\process.jl:466
 in #spawn#413(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}, ::Bool, ::Bool) at .\process.jl:477
 in run(::Cmd) at .\process.jl:591
 in repl_cmd(::Cmd, ::Base.Terminals.TTYTerminal) at .\client.jl:91

As I’m a beginner at Julia, I’m not quite sure what to make of the error message.


#2

dir isn’t an executable, it’s a cmd shell built-in. “shell mode” on windows doesn’t go through the cmd interpreter, since that has so many corner cases it’s not really worth the implementation complexity. You could prefix everything with powershell which is probably a bit more useful.


#3

Ah I see. Thanks for the clarification!


#4

Would it be possible for Julia to detect whether powershell is available, and if so, use it as the default shell?


#5

Powershell should always be available since vista. It has a rather unfortunate first-time startup delay which is the main reason past PR’s to make it the default didn’t get very far. I’d encourage someone to develop a package for a powershell repl mode. There’s an open base issue on making repl mode extension mechanisms more official and able to coexist in a nicer way via a switcher menu rather than having to fight over keys.