Run code non-interactively from script with -e option

How do I escape correctly the quotation marks in

C:\Users\mzaffalon>julia -e 'println("hello world")'

on a Windows machine? The line above gives

ERROR: syntax: character literal contains multiple characters
Stacktrace:
 [1] top-level scope
   @ none:1
julia -e "println(\"hello world\")"

works for me.

1 Like

Related to this: I would like to start a GUI that uses Gtk.jl by double clicking on a batch file; at the same time after the GUI starts, I would like to have the REPL open. I don’t want to put the script below in the startup file, so I call julia gui.jl at the command line where gui.jl contains

using Gtk
win = GtkWindow("GUI")
push!(win,GtkButton("Click Me"))
showall(win)

if !isinteractive()
    @async Gtk.gtk_main()
    Gtk.waitforsignal(win,:destroy)
end

as suggested in the manual Non REPL Usage. However no interactive REPL is started.

If I remove the if !isinteractive() ... end statement, and I start the script using julia -L gui.jl, I get a responsive REPL together with the GUI.

Is there a better way of doing this or is the -L option meant for this purpose?