# Julia v1.0.0 - Semicolon and right-bracket prefixes not working in Jupyter notebook yet

**URL:** <https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 15, 2018, 2:51pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504 "2018-08-15T14:51:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)\
**Post date:** [August 15, 2018, 2:51pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/1 "2018-08-15T14:51:10Z")

</div>

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

```
import Pkg
Pkg.status()

```

etc. But the semicolon prefix, e.g.

```
;ls

```

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?

---

<div class="post-metadata">

**Author:** ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)\
**Post date:** [August 17, 2018, 3:35pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/2 "2018-08-17T15:35:48Z")

</div>

Partial solution:

```
run(`ls`)

```

This still doesn’t answer my question, but at least I can run shell commands within the notebook using `run()`.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 17, 2018, 5:57pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/3 "2018-08-17T17:57:53Z")

</div>

You can run the Pkg REPL from the string macro:

```julia
using Pkg
pkg"add Example"
pkg"up"

```

etc.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 17, 2018, 6:24pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/4 "2018-08-17T18:24:17Z")

</div>

> [@ronubi](#):
>
> But the semicolon prefix […] seems to cause a kernel exception.

This is fixed in the latest IJulia version.

The `]`, analogous to the REPL pkg mode, is not yet supported, but as others have pointed out you can just call `Pkg` functions directly.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 17, 2018, 6:57pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/5 "2018-08-17T18:57:23Z")

</div>

> [@stevengj](#):
>
> The `]` , analogous to the REPL pkg mode, is not yet supported, but as others have pointed out you can just call `Pkg` functions directly.

`]` support is forthcoming:

> <https://github.com/JuliaLang/IJulia.jl/pull/715>
>
> Similar to our support for shell mode with cells starting with \`;\`.

---

<div class="post-metadata">

**Author:** ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)\
**Post date:** [August 17, 2018, 8:16pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/6 "2018-08-17T20:16:03Z")

</div>

Thanks! I just updated and tested it.

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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 17, 2018, 8:41pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/7 "2018-08-17T20:41:30Z")

</div>

> [@ronubi](#):
>
> 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, […] 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.

The whole point of `run` is that you are not using the shell, so you don’t have to quote weird characters, spaces, etcetera. See

- [Shelling Out Sucks](https://julialang.org/blog/2012/03/shelling-out-sucks) and [Put This In Your Pipe](https://julialang.org/blog/2013/04/put-this-in-your-pipe)
- [https://docs.julialang.org/en/stable/manual/running-external-programs/](https://docs.julialang.org/en/stable/manual/running-external-programs/)

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](https://github.com/vtjnash/Glob.jl) package to avoid the shell.

For example, your `ls -lrt *.dat | cat -n | tail -20` example can be written

```julia
using Glob
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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 17, 2018, 8:51pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/8 "2018-08-17T20:51:41Z")

</div>

> [@stevengj](#):
>
> it doesn’t actually pipe directly to `/bin/sh` or whatever shell.

Actually, `; cmd` does execute through the shell ([run `;cmd` through a shell by StefanKarpinski · Pull Request #4635 · JuliaLang/julia · GitHub](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.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [August 17, 2018, 8:53pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/9 "2018-08-17T20:53:36Z")

</div>

We used to. @jameson didn’t like it.

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [August 17, 2018, 10:56pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/10 "2018-08-17T22:56:25Z")

</div>

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](https://github.com/JuliaLang/julia/issues/10120#issuecomment-141253631). 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](https://github.com/JuliaLang/julia/issues/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](https://github.com/JuliaLang/julia/pull/3472))

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 18, 2018, 12:10pm UTC](https://discourse.julialang.org/t/julia-v1-0-0-semicolon-and-right-bracket-prefixes-not-working-in-jupyter-notebook-yet/13504/11 "2018-08-18T12:10:14Z")

</div>

> [@jameson](#):
>
> Stevengj’s proposal has been noted before and, I think, still has merit: [#10120](https://github.com/JuliaLang/julia/issues/10120#issuecomment-141253631).

What about just doing something simpler: passing the string after `;` through to the shell unaltered? If you want to interpolate Julia variables etcetera you can use `run`.
