# Can the Julia shell be changed to \`/bin/bash\`?

**URL:** <https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500>\
**Category:** New to Julia\
**Tags:** question, shell\
**Created:** [November 11, 2024, 2:54pm UTC](https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500 "2024-11-11T14:54:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![world-peace](https://avatars.discourse-cdn.com/v4/letter/w/9f8e36/32.png) [@world-peace](https://discourse.julialang.org/u/world-peace)\
**Post date:** [November 11, 2024, 2:54pm UTC](https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500/1 "2024-11-11T14:54:04Z")

</div>

I’ve just learned that the Julia shell is not `/bin/sh` as I had assumed. It is it’s own thing, apparently.

Can the default shell be changed so that a `/bin/bash` shell is launched when the Shell Mode key `;` is pressed?

I’m aware that I can run `bash` from the Julia Shell. But why press another 5 keys if you dont have to, right?

This is really an aside but -

I’m not quite sure what the intended purpose of the Julia Shell is. It doesn’t seem to make much sense to re-invent the wheel here - but I guess that’s another thread in itself, potentially. Someone can tell me if there’s an obvious reason why Julia has its own shell rather than using a native OS one, if there is a reason for it which I’ve overlooked.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 11, 2024, 3:07pm UTC](https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500/2 "2024-11-11T15:07:29Z")

</div>

> [@world-peace](#):
>
> Can the default shell be changed so that a `/bin/bash` shell is launched when the Shell Mode key `;` is pressed?

I suppose it _could_. This IS by design, as I explained in the other answer, to be cross-platform. You can’t rely on e.g. `bash` installed, or any shell even `sh`; you might even run on a platform with no shell (all supported platforms have _some_ shells, at least Windows with `cmd`, I mean just in theory some [future, e.g. a microcontroller] might have none available), i.e. no specific shell is preinstalled on all of Julia’s supported platforms. E.g. not `bash` on Windows (though by now with WSL2, wasn’t available when Julia was designed), and PowerShell _not by default_ on Linux (but IS available there). Julia doesn’t want to bundle a shell (nor a terminal) with, making julia even larger, so it supports some common subset working on all platforms.

Note there is ReplMaker.jl that people have used to make their own modes (such as **[SQLREPL.jl](https://github.com/c42f/SQLREPL.jl)** that I nerdsniped into existence), in addition to `;` for the default shell mode (I’m not sure it allows changing a specific mode, maybe it does, at least an improved mode could be prototyped with it).

Basically anything is possible in Julia, i.e. is dynamic, so you could even change the default shell [code to do anything, such as you ask for], to e.g. call bash, or PowerShell, such a package could even bundle either (or both!). I don’t know that anyone has done this, and you might not use that tool to do it, except to prototype at first.

> [@world-peace](#):
>
> Someone can tell me if there’s an obvious reason why Julia has its own shell rather than using a native OS one, if there is a reason for it which I’ve overlooked.

It’s for quick ls, dir, etc. Note on Windows you have dir not ls (at least historically), and vice versa. I see I actually have dir also in Mint (and any Linux, e.g. Ubuntu) by now. If I recall Julia may support ls even when absent on Windows.

EDIT: I see `dir` does NOT actually work (or docs outdated? would with PowerShell?) on Windows (neither ls?):

> **[The Julia REPL · The Julia Language](https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode)**
>
> Documentation for The Julia Language.

> For Windows users, Julia’s shell mode does not expose windows shell commands. Hence, this will fail:

> [@Documentation for shell mode?](https://discourse.julialang.org/t/documentation-for-shell-mode/55564/2):
>
> 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

> <https://github.com/JuliaLang/julia/blob/f93138ed0791799bf4bd33649cb3269054474a24/stdlib/REPL/src/REPL.jl#L814-L814>

I see some code specific for ~ on Unix/Linux and some Windows specific too:

> <https://github.com/JuliaLang/julia/blob/f93138ed0791799bf4bd33649cb3269054474a24/stdlib/REPL/src/REPLCompletions.jl#L473-L473>

> <https://github.com/JuliaLang/julia/pull/33827/files#diff-d48b8f45e044ee1cbdfefdf19a41cc647cb962e0ef8f0b211c98aa786229abfb>
>
> @staticfloat I think this might be more reliable (closer to what the internal co…de does)?

---

<div class="post-metadata">

**Author:** ![savq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/savq/32/22063_2.png) [@savq](https://discourse.julialang.org/u/savq)\
**Post date:** [November 12, 2024, 3:33am UTC](https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500/3 "2024-11-12T03:33:23Z")

</div>

Julia command literals (created with backticks) exist for a good reason. 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/). TL;DR spawning a shell to spawn processes is more expensive and fragile than spawning the process directly.

The syntax for command literals is quite limited because ultimately Julia just creates a list of strings that are then passed to Libuv. Things like pipes, globs, `&&` would have to be implemented in Julia itself because Libuv doesn’t handle them (there’s an issue about it, see Julia#20401).

Now, the REPL shell mode (entered with `;`) has the same _syntax_ as command literals but confusingly, it’s not always executed as a regular `Cmd`! The REPL will parse the command with Julia’s own syntax, but then it’ll call [Base.repl\_cmd](https://github.com/JuliaLang/julia/blob/501a4f25c2b7626c5e368cd01d1c050b70bafdb9/base/client.jl#L34), which will spawn a shell (except on Windows because 🤷). So the linked comment is sorta wrong.

Why does it work that way? I’ve got no idea… and I still find it really confusing.

> EDIT: I see dir does NOT actually work (or docs outdated? would with PowerShell?) on Windows (neither ls?):

Yep. since the REPL doesn’t shell out on Windows, no built-in will work. You’d need an `ls` binary in your windows system for it to work.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [December 7, 2024, 10:02pm UTC](https://discourse.julialang.org/t/can-the-julia-shell-be-changed-to-bin-bash/122500/4 "2024-12-07T22:02:32Z")

</div>

I believe the manual is not clear enough about this. Quoting from [the relevant section](https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode):

> Just as help mode is useful for quick access to documentation, another common task is to use the system shell to execute system commands. Just as `?` entered help mode when at the beginning of the line, a semicolon (`;` ) will enter the shell mode. And it can be exited by pressing backspace at the beginning of the line.

The text mentions “the system shell”, which could easily mislead readers in thinking that they’re getting Bash on Linux.
