-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 for Windows #23703
REPL shell mode for Windows #23703
Conversation
Thanks for revisiting this. In general it's better to update PRs than open new ones but this is fine. |
LGTM, but probably someone with more Windows shell expertise like @tkelman should chime in. |
JULIA_SHELL should be documented in https://github.com/JuliaLang/julia/blob/master/doc/src/manual/interacting-with-julia.md#shell-modeid-man-shell-mode |
I don't think anything should ever default to cmd. |
@tkelman, isn't Wouldn't defaulting to e.g. PowerShell be even more confusing to someone who just wants Alternatively, I'd be all for bundling something like busybox or toybox on Windows so that people can use the same Unix shell commands on all platforms (with the uniformity outweighing the non-native feel of |
Familiar, maybe, but also the least useful to interact with programmatically. Powershell has default aliases, both cmd and posix names, for many things. It does have an unfortunate first-time startup latency though. We already do bundle busybox, but it only gets used by a few tests. I've never been bothered enough by "dir doesn't work in shell mode" to feel the need to rely on it more heavily though. It currently gets left out of a no-GPL build for uniformity's sake, though the viral parts of the GPL don't apply to how we use it. |
So can we default to busybox, to make the shell mode portable? |
We could also default to Julia's shell mode everywhere, which is also portable. |
@vtjnash, but then we get an endless stream of complaints that |
Anything with a binary (such as
|
Yes, but the problem is that Windows does not have binaries for One alternative option would be for the shell mode on Windows to preprocess the Cmd object and transform a few common shell functions like The basic issue here is to make the default REPL shell mode more usable on Windows. |
Should also be able to run any binary with this PR.
This is effectively what windows It seems some people might want the familiarity of Current PR allows users to select shell mode by setting |
Making the default "no shell" means that the default will seem broken for many users. Furthermore, it is precisely the new users confused by this who will also have a hard time learning about an "unbreak me" |
100% agree with @stevengj. As a purely interactive feature user-friendliness trumps other concerns. |
Precisely. It will seem broken for those users that want I think Are there any examples of commands that can be run now, but you think can't be run via |
I have to 100% disagree. I entirely stopped being able to use shell mode once #4635 merged, and now never use it (and I originally implemented it, iirc). |
Then you are clearly not the target demographic for this feature. You've never explained why this feature became "unusable" to you, so it's impossible to make progress towards something that works for you as well as for the many others who are happy with the way this works currently (except on Windows where it's unusable precisely because it has the behavior you claim is "unusable"). |
I opened an issue for that #10120 and you are self-assigned to solve it. Currently, I don't think it's possible to pass the character |
base/client.jl
Outdated
nothing | ||
end | ||
|
||
function repl_cmd(iswindows::Val{true}, line::AbstractString, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use Val
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm thinking I will just use a single run-time if
statement within a common repl_cmd
method.
Just for my own edification, why is using Val
not recommended? Is it a performance issue?
I thought iswindows()
would be known at compile time?
Are there any cases where using Val
is OK?
That's a bug – saying that it makes shell mode "unusable" is quite dramatic. Feel free to fix said bug, I'm not territorial. |
If I thought it was fixable, don't you think I would have submitted a PR instead of ceasing to use it? My conclusion at the time was that its behavior was unpredictable-by-design, so I stopped attempting to use it. |
Calling it unusable on Windows is a bit of an exaggeration. Other than |
@stevengj What is the exact problem? The GPL explicitly doesn't extend to "mere aggregation" It's puzzling as "mere aggregation" should apply for busybox. We could do everything right, but someone downstream distributing Julia could get in trouble (unless we distribute source code of busybox with?): https://torquemag.io/2013/03/busybox/
|
What I quoted on busybox sounds like FUD so I dug deeper, busybox copyright lawsuits are used as a lever against Linux kernel GPL violations (even if copyright owners of it don't want to sue). My reading of this is that even if http://mjg59.dreamwidth.org/10437.html
|
If you still want to use busybox, there's: https://github.com/rmyorston/busybox-w32 "WIN32 native port of BusyBox." If you distribute [binary] code meant for Windows, I guess the "Linux kernel lawsuit lever" is out.. or not as likely to lead to a lawsuit. Just speculating on "mere aggregation" issue above, maybe it didn't apply, as busybox intentionally statically links shell command binaries together (we wouldn't link busybox as a whole with Julia.exe); maybe that wasn't the limit, not sure if a firmware would have one giant binary with the busybox + the Linux kernel statically linked.. |
One question, since most users, at least developers will be on Windows 10, is busybox relevant? Can't you just use bash from the Linux subsystem for the shell mode only? Even keeping Julia (otherwise) a pure Windows build (not an ELF build for the subsystem). |
@PallHaraldsson, as I explicitly commented above, I don't think either shipping busybox with Julia ("mere aggregation") or executing it via fork/exec would be a problem. (That is, it wouldn't affect the licensing terms of Julia programs.) The only question in my mind is whether Windows users would prefer a Windows shell (e.g. cmd), or if the superiority of the POSIX shell tools and the advantage of having the same Julia shell commands cross-platform would win. I favor the latter, but I'm obviously biased since I don't normally use Windows. |
I've tried to update some manual pages, but it seems like something isn't right, and tests are failing. EDIT: OK now fixed. |
base/client.jl
Outdated
elseif cmd[1] == "cd" && length(cmd) <= 2 | ||
repl_cd(cmd, shell, out) | ||
else | ||
run(ignorestatus(isa(STDIN, TTY) ? `$shell -i -c "$(shell_wrap_true(shell_name, cmd))"` : `$shell -c "$(shell_wrap_true(shell_name, cmd))"`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be written a little more cleanly as
ttyopt = STDIN isa TTY ? "-i" : ""
run(ignorestatus(`$shell $ttyopt -c "$(shell_wrap_true(shell_name, cmd))"`))
since -i
is the only thing that differs between the two branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course, will update.
Although probably better to use command syntax rather than strings:
ttyopt = STDIN isa TTY ? `-i` : ``
https://discourse.julialang.org/t/interpolating-an-empty-string-inside-backticks/2428/3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, good call. I had forgotten about that.
docs have been updated |
Would be nice to see this resurrected in some form… |
Ping. This didn't make it into 1.0, but it is not breaking (just a REPL feature), so it could go into 1.1. |
bump also looking forward to this. ref https://discourse.julialang.org/t/newbi-first-steps-in-julia-for- |
Bump? Looks like someone else has to take over this PR if @GregPlowman is too busy on other things these days… |
c.f. #30614, which implements the escaping function (print_shell_escaped_windows) that's needed to shell out to |
|
||
if isempty(cmd.exec) | ||
cmd = cmd_gen(eval(Main, shell_parse(line)[1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there shouldn't be any calls to eval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eliminated in the updated PR
Closing this in favor of the simplified and rebased #31490. I would have updated this PR, but it didn't look like I had the permissions? |
Replaces stale PR #21294
cc: @stevengj
Summary:
JULIA_SHELL
can be set to:--
cmd
--
powershell
--
busybox
-- "" for no shell, execute command directly (current behavior)
cmd
is default for Windows users.For Windows, the raw line is processed, rather than converting to
Cmd
and then re-assembling into a Windows command line. Windows shell commands are passed as a string anyway, so this gives the user more control over any escaping. I think it works quite well.Modified special handling of
cd
. When there are 2 or more arguments, command line is processed as normal, rather than throwing an error. This allows commands such ascd $dir && $command
to be executed.