The Julia shell doesn't have an environment variable $SHELL?

What is the Julia shell?

It doesn’t appear to have an environment variable $SHELL. Normally most (Linux) shells define this environment variable to tell the user that the current shell is a Bash shell or /bin/sh shell, etc.

I’m just wondering, is the default Julia shell an instance of /bin/sh, or is it its own separate Julia shell thing?

No. And I think the reason is for the shell mode to be cross-platform, also good enough for most things. The other answer is probably what you were really asking for, but I’m editing mine here.

Isn’t $SHELL just for interactive shells?

Julia isn’t a shell. It has a REPL, if you meant that, and it’s somewhat similar to an interactive shell (and Julia however has a shell mode from the REPL, and then it’s similar but not same as bash, e.g. you are missing piping there, so I often tend to go to shell mode then bash to get all capabilities, and CTRL-D to get back).

Shells are used as either interactive (maybe, maybe not with programming features), and Julia isn’t a substitute, e.g. you can’t just type commands, you would have to do command and use |> not just | for piping.

Or shells are used for programs, and Julia is a rather good substitute then (you can pipe into and out of Julia programs with your regular shell), just not with compatible syntax (within the Julia program, invoking it from your shell is the same, i.e. same syntax). It actually has better semantics than most or all shells.

The main issue historically was slower startup of Julia programs, it’s gotten a lot better, much closer to Python’s now, but still far from e.g. perl’s or bash startup. There are tools to mitigate. With and even without tools, Julia can be faster, i just has to be long-running enough to make up for the slower startup.

It’s a simple thing which splits the command into “words”, and does a fork/execve on the result. Or, equivalently, escapes every metacharacter before it is given as a command to bash. If you do something like shell> echo $SHELL it will try to interpolate a julia variable SHELL, not an environment variable. However, shell> printenv SHELL gives you “/bin/bash”.

1 Like

Right, why would you want to have access to it? In general for any ENV var you can have access to them in Julia this way, and even go to your favorite shell:

julia> ENV["SHELL"]
"/bin/bash"

shell> $(ENV["SHELL"])

$

Now I’m in bash. Such most probably wouldn’t work in Windows, it has env vars, but I doubt it has $SHELL, so I’m not sure how you would to this cross-platform, in the shell mode.

See:
help?> run

1 Like