# Documentation for shell mode?

**URL:** <https://discourse.julialang.org/t/documentation-for-shell-mode/55564>\
**Category:** New to Julia\
**Created:** [February 18, 2021, 5:47pm UTC](https://discourse.julialang.org/t/documentation-for-shell-mode/55564 "2021-02-18T17:47:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielIngraham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielingraham/32/13055_2.png) [@DanielIngraham](https://discourse.julialang.org/u/DanielIngraham)\
**Post date:** [February 18, 2021, 5:47pm UTC](https://discourse.julialang.org/t/documentation-for-shell-mode/55564/1 "2021-02-18T17:47:45Z")

</div>

I really like the REPL’s shell mode (the thing you get after typing `;`). But I struggle with understanding which features of my normal `$SHELL` are available, and which don’t work. I’ve read [the official docs](https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode), but I can’t find the answers to these questions:

- Why aren’t the aliases I define in my e.g. `~/.zshrc` available?
- Can I do any job control (run things in the background with `&`, etc.)?
- Why can’t I set shell variables?

Is there anywhere I can find the answers to this questions?

I run Julia on Linux if it matters, and I use `zsh` as my shell.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 18, 2021, 5:49pm UTC](https://discourse.julialang.org/t/documentation-for-shell-mode/55564/2 "2021-02-18T17:49:40Z")

</div>

Julia shell is not really using \*your shell. In fact, it’s not running a shell at all, for example, `ls *` doesn’t work because `*` is expanded by shell program (bash, zsh) and Julia is not using any of them.

you can, however, run `zsh` as the first thing at `shell >` and that will drop you into your zsh. But I don’t think that is a particularly useful workflow, you might as well just `Ctrl-Z` the Julia instead

---

<div class="post-metadata">

**Author:** ![DanielIngraham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielingraham/32/13055_2.png) [@DanielIngraham](https://discourse.julialang.org/u/DanielIngraham)\
**Post date:** [February 20, 2021, 12:10pm UTC](https://discourse.julialang.org/t/documentation-for-shell-mode/55564/3 "2021-02-20T12:10:54Z")

</div>

Thanks for the reply!

> [@jling](#):
>
> Julia shell is not really using \*your shell. In fact, it’s not running a shell at all, for example, `ls *` doesn’t work because `*` is expanded by shell program (bash, zsh) and Julia is not using any of them.

After looking at the code a bit more, I think it’s the opposite: Julia is escaping special characters before passing a command to my shell. I think the escaping is done by `Base.shell_parse` [julia/base/shell.jl at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/base/shell.jl) before being passed to my shell through `Base.repl_cmd` [julia/base/client.jl at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/base/client.jl#L33). I think that happens for the `;` shell mode in `REPL.jl`: [julia/stdlib/REPL/src/REPL.jl at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/stdlib/REPL/src/REPL.jl#L921).

So I guess the next question is: why does Julia need to escape special characters like `*` before passing them to the shell?

Thanks!

Daniel

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 20, 2021, 7:45pm UTC](https://discourse.julialang.org/t/documentation-for-shell-mode/55564/4 "2021-02-20T19:45:20Z")

</div>

it’s not about the escaping:

```julia
julia> run(`ls *`)
ERROR: LoadError: parsing command `ls *`: special characters "#{}()[]<>|&*?~;" must be quoted in commands
Stacktrace:

julia> run(`ls \*`)
ls: cannot access '*': No such file or directory
ERROR: failed process: Process(`ls '*'`, ProcessExited(2)) [2]

```

It’s passing `*` to `ls` just fine, but you have to realize that `ls` doesn’t know what to do with `*`. In a shell like `bash`, when you execute `ls *`, shell expands the `*` before passing arguments to `ls`. Julia shell doesn’t do that, it passes the argument (`*`) to `ls` directly – because Julia is not running a shell for you.

To further demonstrate this point, the following works by invoking a shell that expands `*`:

```julia
julia> run(`sh -c ls \*`)
...
..
.

```
