Skip to content

Conversation

@GregPlowman
Copy link
Contributor

Take 2 for #20776
(I made a mistake with GitHub when trying to modify that PR, sorry)

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 as cd $dir && $command to be executed.

shell = shell_split(get(ENV,"JULIA_SHELL",get(ENV,"SHELL","/bin/sh")))
shell_name = Base.basename(shell[1])
function repl_cmd(line::AbstractString, out)
if is_windows()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use @static when conditioning on the OS inside a function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not unless you're emitting code that doesn't compile on multiple platforms, or you really need to eliminate the comparison for runtime performance. better to leave the static out if neither is the case, have all branches at least get compiled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think on v0.6, code is conditionally compiled with and without @static
So maybe there's no runtime performance difference?

Both test1() and test2() produce the same llvm:

test1() = is_windows() ? 1 : "a"
test2() = @static is_windows() ? 1 : "a"
julia> @code_llvm test1()

; Function Attrs: uwtable
define i64 @julia_test1_68517() #0 !dbg !5 {
top:
  ret i64 1
}

julia> @code_llvm test2()

; Function Attrs: uwtable
define i64 @julia_test2_68518() #0 !dbg !5 {
top:
  ret i64 1
}

@ararslan ararslan added REPL Julia's REPL (Read Eval Print Loop) system:windows Affects only Windows labels Apr 6, 2017
@stevengj
Copy link
Member

stevengj commented Sep 7, 2017

Bump — would be nice to see this merged in some form.

@GregPlowman
Copy link
Contributor Author

Replaced by #23703

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

REPL Julia's REPL (Read Eval Print Loop) system:windows Affects only Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants