Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL shell mode is incompatible with nushell #54291

Open
MilesCranmer opened this issue Apr 28, 2024 · 4 comments
Open

REPL shell mode is incompatible with nushell #54291

MilesCranmer opened this issue Apr 28, 2024 · 4 comments

Comments

@MilesCranmer
Copy link
Sponsor Member

It seems that the nushell shell is incompatible with the Julia REPL at the moment. When I hit ; in the Julia REPL to open the shell, and write any command, I get this:

julia> ;
shell> echo "Hello World"
Error: nu::parser::shell_andand

  × The '&&' operator is not supported in Nushell
   ╭─[source:1:22]
 1 │ (echo 'Hello World') && true
   ·                      ─┬
   ·                       ╰── instead of '&&', use ';' or 'and'
   ╰────
  help: use ';' instead of the shell '&&', or 'and' instead of the boolean '&&'

I think the Julia REPL should either be made compatible with nushell, or it should run commands in a compatible shell like bash. Right now I can't seem to do anything in the shell mode because my default shell is nushell.

Context: Nushell is a new type of cross-platform shell written in pure rust: https://github.com/nushell/nushell/. Instead of "&&" they use "and" (among several other differences).

@jakobjpeters
Copy link

I also would like to use nushell. This Discourse post says that shell mode only supports POSIX shells and that one can set the JULIA_SHELL environment variable as a workaround.

@Seelengrab
Copy link
Contributor

The shell> mode in the REPL doesn't actually spawn a shell, and instead evokes programs directly IIRC. How does this end up calling into nushell in the first place?

@MilesCranmer
Copy link
Sponsor Member Author

I’m not sure how it gets called. Maybe if JULIA_SHELL is unset it simply takes SHELL?

But where does the && come from? All that needs to be changed is that. Is that from run?

At the bottom of #23597 @xgdgsc and @stevengj were also discussing Nushell as a potential solution to having a shell mode on windows.

@KristofferC
Copy link
Sponsor Member

KristofferC commented Apr 29, 2024

The shell> mode in the REPL doesn't actually spawn a shell, and instead evokes programs directly IIRC

I think the shell mode does spawn a shell. Perhaps you are thinking about run?

Anyway, a small tweak to

julia/base/client.jl

Lines 63 to 68 in 6023ad6

if shell_name == "fish"
shell_escape_cmd = "begin; $(shell_escape_posixly(cmd)); and true; end"
else
shell_escape_cmd = "($(shell_escape_posixly(cmd))) && true"
end
cmd = `$shell -c $shell_escape_cmd`

could probably fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants