I realize that there are bound to be issues with the latest release, and that I may not have set up everything correctly with the new Pkg system, but I was pleasantly surprised that I could
$ julia100 # my symlink for Julia v1.0.0
] add Plots
] add IJulia
(from Mac terminal), so I launched jupyter-notebook and it let me start a new notebook with the Julia 1.0.0 kernel! So I’m playing around. First thing I discovered was that the right-square-bracket prefix doesn’t work, but that’s no biggie because I can
etc. But the semicolon prefix, e.g.
seems to cause a kernel exception. Am I doing something wrong, or should I just wait for an update to Julia or the IJulia package?
BTW, is there a straightforward way to escape/quote wildcards/regex/special-chars in a system command? I’m used to using the bang (!) prefix in Matlab do run arbitrarily complex command lines, e.g.
>> !ls -lrt *.dat | cat -n | tail -20
but haven’t figured out how to do this with Julia’s run, @cmd, or even using run(pipeline()). I get a warning about having to quote special characters, but I’m not sure how to do it. Any advice would be appreciated.
You aren’t using the shell, however, so you have to use Julia’s pipeline function instead of | for piping. If you want globbing like *.dat, you can use the Glob.jl package to avoid the shell.
For example, your ls -lrt *.dat | cat -n | tail -20 example can be written
run(pipeline(`ls -lrt $(glob("*.md"))`, `cat -n`, `tail -20`))
If you actually want to use the shell, you need to do something like run(`/bin/sh -c "ls -lrt *.dat | cat -n | tail -20"`) — the “shell” mode of ; uses run, it doesn’t actually pipe directly to /bin/sh or whatever shell.
Actually, ; cmd does execute through the shell (https://github.com/JuliaLang/julia/pull/4635) unless that behavior was changed? But it still parses the string as a Cmd object first. I wonder if it would be better to just sling the whole string at the shell.
No, it never did that. At some point, I fixed a bug in escape, which people for some reason seemed to assume was intended behavior (the old code called shell_escape, but assumed that only the “intended” parts of the result are actually correctly escaped and the rest were somehow copied verbatim from the pre-parsed representation). Stevengj’s proposal has been noted before and, I think, still has merit: #10120. I somewhat recall implementing something more like this prior to the initial PR, but originally we eventually concluded it was better not to create a weird hybrid and instead make this just a simple pass-through to calling run (+ some magic for cd as a builtin). I’m not opposed to re-visiting that decision, although I like #20401 more.
(historical note: hilariously, we were strongly considering using ? as the character operator to invoke this. what a tragic mistake that would have been. we also considered using ] too, but decided that embedding a second language off that character would be bad because people might also want to try using it as the API for run in scripts – definitely an odd non-sequiter of a argument, but I guess we were younger then and more foolish. c.f. #3472)